jqGrid Filtering Records

To filter local grid you should only fill filters property of the postData parameter of jqGrid and set additionally search:true.

To save selection of the grid you can use reloadGrid with additional parameter [{page:1,current:true}] (see here).

The corresponding code can be the following

$("#search").click(function() {
    var searchFiler = $("#filter").val(), grid = $("#list"), f;

    if (searchFiler.length === 0) {
        grid[0].p.search = false;
        $.extend(grid[0].p.postData,{filters:""});
    }
    f = {groupOp:"OR",rules:[]};
    f.rules.push({field:"name",op:"cn",data:searchFiler});
    f.rules.push({field:"note",op:"cn",data:searchFiler});
    grid[0].p.search = true;
    $.extend(grid[0].p.postData,{filters:JSON.stringify(f)});
    grid.trigger("reloadGrid",[{page:1,current:true}]);
});

I made the demo for you which filter for two columns ‘Client’ (‘name’) and ‘Notes’ (‘note’) you can extend the code to search in all columns which you need.

Depend on what you exactly mean with the saving row selection you can need to save the current selection from the selarrrow in a variable and restore the selected rows with respect of setSelection method.

Leave a Comment