I have a jqGrid that I'd like to be able to load up with filters already applied (will probably be passed in through the URL). For testing I am hardcoding the filters, but I can't get that to work. I am trying to follow the answer here to get this to work.
My grid code (with some columns removed for simplicity):
<script type="text/javascript">
$(function(){
$("#users").jqGrid({
datatype: 'json',
url: 'myLoadURL',
gridview: true,
loadonce: true,
colModel: [
{name: 'lastname', label: 'Last Name'},
{name: 'firstname', label: 'First Name'},
{name: 'email', label: 'Email'}
],
height:'auto',
autowidth:true,
caption:'Users',
rowNum:20,
rowList:[10,20,50],
ignoreCase: true, // case-insensitive filtering
pager: '#pager',
postData: {
filters: '{"groupOp":"AND",rules:[{"field":"lastname", "op":"cn", "data":"smith"},{"field":"firstname","op":"cn","data":"john"}]}'
},
search:true
});
$("#users").jqGrid("filterToolbar", {searchOnEnter: false});
});
</script>
<table id="users"><tr><td></td></tr></table>
<div id="pager"></div>
In this case I'm trying to filter on users with firstname containing "John" and lastname containing "Smith". All the records are loaded, though. How can I get the initial filter values to apply?