Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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.

like image 284
Anto king Avatar asked Nov 24 '12 14:11

Anto king


2 Answers

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.

like image 81
ffffff01 Avatar answered Nov 18 '22 17:11

ffffff01


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
});
like image 35
bluetech Avatar answered Nov 18 '22 17:11

bluetech