I\'m using jqGrid with the filter toolbar, i need to set an initial default filter value to one of the fields so that only rows with status \'Open\' are displayed by default
There are a few steps to do this:
In a bit more detail:
Set the grid datatype to local (this prevents the initial data load) and set the default value for the search options:
$("#mytable").jqGrid({
datatype: "local",
colNames:['Keyword','Selected'],
colModel:[
{name:'keyword',
sortable:true,
searchoptions: { defaultValue:'golf' }
},
{name:'selected',
sortable:false,
searchoptions: { }
},
....
....
Then add the filter toolbar, set the data type and url, and trigger the load:
$('#mytable').jqGrid('filterToolbar', {autosearch: true});
$('#mytable').setGridParam({datatype: 'json', url:'/get_data.php'});
$('#mytable')[0].triggerToolbar();