How to make filter toolbar in JQGrid case insensitive and set a place holder in it?

12,289

Solution 1

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.

Solution 2

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
});
Share:
12,289
Anto king
Author by

Anto king

I'm working as .Net developer for past one year start with 4.0 now working on MVC3 and keep on learning.....

Updated on July 21, 2022

Comments

  • Anto king
    Anto king almost 2 years

    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.

  • Anto king
    Anto king over 11 years
    Thanks its working and how can i set a place holder inside the search in JQgrid
  • achan1989
    achan1989 over 6 years
    It is not working in jqGrid 3.7.2 Kindly help for alternate solution.