I am using version 4.13.1 of freejqGrid. I just added the code for the filter toolbar, which is working, except that the search parameter disappears after the search. The search works and everything but I would like to leave that text in the toolbar until cleared using the (x).
$('#jqGrid_destroyed').jqGrid({
url:'/url.php',
height: 'auto',
shrinkToFit: true,
width: Math.floor($(window).width()*1),
datatype: 'json',
mtype: 'POST',
colNames:[
'Flat ID',
'Customer',
'Flat #',
'MiscCode',
'Item Number',
'Item Description',
'plus',
'RevDate',
'Created Date',
'Plate/Flat in QA',
'Computer Files to Waiting Destruct',
'Plates/Flat Destroyed',
'Date Confimation Sent to Customer'
],
colModel:[
{name:'flat_id',hidden:true},
{width:14,name:'Customer'},
{width:10,name:'flat_plate_num'},
{width:13,name:'MiscCode'},
{width:20,name:'item_number'},
{width:45,name:'item_description'},
{width:12,name:'plus'},
{width:16,name:'revdate'},
{width:22,name:'created_date', align: "right", hidden:true},
{width:17,name:'flat_in_qa'},
{width:20,name:'computer_files_to_waiting_destruct'},
{width:25,name:'flat_destroyed'},
{width:20,name:'date_confimation_sent_to_customer', formatter : 'date', formatoptions : {srcformat: "Y-m-d", newformat:"m/d/Y"}}
],
sortname: 'date_confimation_sent_to_customer',
sortorder: 'desc',
viewrecords: true,
gridview: true,
caption: 'Waiting Destruct',
rowNum: 10000,
pager:true,
searching: { defaultSearch: "cn" }
}).jqGrid("filterToolbar");
Free jqGrid 4.13.1 introduced new feature - filling of the filter toolbar based on the
postData.filters
. See the README4.13.1. The feature had some bugs, which exists in your case. The bugs are fixed in the later version of free jqGrid.One can switch off the feature by usage
loadFilterDefaults: false
(by usage.jqGrid("filterToolbar", {loadFilterDefaults: false})
or better by changingsearching: { defaultSearch: "cn" }
tosearching: { defaultSearch: "cn", loadFilterDefaults: false }
). On the other side I would better recommend you to update to the current released version of free jqGrid: 4.13.5 or to use the latest sources from GitHub.The searching option
loadFilterDefaults: false
is very practical in many scenarios. For example one can use both filter toolbar and the Searching Dialog. If you would set some filter in the filter toolbar and then opening Searching Dialog, then you will see the current filter in the dialog. You can modify it and apply the new filter. The grid will show the new filter, but the old versions of jqGrid will still display old filter in the filter toolbar. I posted the old answer, which shows how one can fill the filter toolbar based on the current used filter. The new version of free jqGrid will refresh the filter toolbar automatically if the defaultloadFilterDefaults: true
option of thefilterToolbar
is used.There are other common scenarios where
loadFilterDefaults: true
would be helpful. One can, for example, load all JSON data from the server usingloadonce: true
option. Free jqGrid allows to combineloadonce: true
option withforceClientSorting: true
, which apply local sorting and filtering before the data will be displayed in the grid. It allows to load all the data, but display only filtered and sorted data with paging the data locally. To filter the data one need just setfilters
property ofpostData
. By usagefilterToolbar
with defaultloadFilterDefaults: true
option one will see the currently applied filter, which could be helpful for the user.