9

Sometimes I was not getting some small things easily.

Today my problem is I am using JQgrid in that I was using filter toolbar to search.

It is working fine, but what I need is that search is only doing with case sensitive.

Example:"A"

If I give it is showing Result Antony. But if I give "a" its not showing anything how to I make it case in sensitive.

Here is my code:

<script type="text/javascript">
$(document).ready(function () {
    var lastsel3;
    var cl;
    var a = new Date();
    var QColName = a.getFullYear();
    var Q4ColName = (a.getFullYear()) + 1;
    var json_string = document.getElementById("hdntxt").value;

    if (json_string.length > 0) {
        var search_result = $.parseJSON(json_string);
    }
    jQuery("#gvLockHistory").jqGrid({
        contentType: "application/json; charset=utf-8",
        height: 'auto',
        width: '480',
        gridview: true,
        datatype: "local",
        data: search_result,
        colNames: ['Type', 'Month', 'Action'],
        colModel: [
        { name: 'LockType', index: 'LockType', editable: false, sortable: true, align: 'center',width:158 },
        { name: 'MonthYearStringValue', index: 'MonthYearStringValue', editable: false, sortable: false, align: 'center', width: 157 },
        { name: 'IsActive', index: 'IsActive', editable: true, align: 'center', sortable: false, search: false, width: 150 }
        ],
        rowNum: 8,
        pager: '#pager',
        rowList: [8, 10, 20, 30],
        multipleSearch: true,
        multipleGroup: true,
        shrinkToFit: false,
        viewrecords: true,
        caseSensitive: false,
        sortorder: "desc",
        //editurl: "server.php",
        gridComplete: function () {
            var ids = jQuery("#gvLockHistory").jqGrid('getDataIDs');
            for (var i = 0; i < ids.length; i++) {
                cl = ids[i];
                //be = "<input class='btn btn-mini' type='button' value='Unlock' onclick=\"unlock('" + cl + "');\"  />";
                be = "<input class='btn btn-mini' type='button' value='Unlock' onclick=\"unlock('" + cl + "');\"  />";
                jQuery("#gvLockHistory").jqGrid('setRowData', ids[i], { IsActive: be });

            }
        }
    });

This is i was search in net to make case insensitive but its not working

    $("#gvLockHistory").filterToolbar({ stringResult: true, searchOnEnter: false,defaultSearch:"cn"});


});

Please help me thanks in advance. And please don't forget about the place holder which need to display in filter section.

2 Answers 2

26

If you are using a relatively new version of jqgrid you can set the following option to make the search case insensitive:

ignoreCase: true

Hope it helps.

2
  • Thanks its working and how can i set a place holder inside the search in JQgrid
    – Anto king
    Nov 26, 2012 at 5:03
  • It is not working in jqGrid 3.7.2 Kindly help for alternate solution.
    – achan1989
    Dec 29, 2017 at 8:37
13

You need to set ignoreCase: true in jqGrid options. The answer by @f01 did not work for me. I am using jqGrid version 4.6.0.

grid.jqGrid({
    datatype: "local",
    editurl: 'clientArray',
    caption: "Values",
    ignoreCase: true, //By default the local searching is case-sensitive. 
                      //To make the local search and sorting not 
                      //case-insensitive set this options to true

    colNames: ["", "", ""],
    colModel: [{
        name: "value",
        // .. more stuff
});

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.