There are a few steps to do this:
- pass a default value in the column model search options
- prevent the default form data load process
- trigger a filter toolbar data load when the table is ready
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();
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…