Reputation: 11
jQuery("#grid").jqGrid({
url:'admin/name.php',
postData: {userid: user_id},
datatype: 'json',
mtype: 'POST',
height: "auto",
width: 'auto',
rowNum: 20,
rowList: [10,20,30],
colNames:[' name','Job ',' Term','Date'],
colModel :[
{name:'name', index:'name', width:100},
{name:'Job', index:'Job', width:150},
{name:'Term', index:'Term', width:70},
{name:'Date', index:'Date', width:100},
],
pager: "#p_grid",
viewrecords: true,
toolbar: [true, 'both'],
caption: "grid",
});
$("#grid").jqGrid('navGrid','#p_grid',{edit:true,add:true,del:true,search:true,refresh:true});
jQuery("#grid").filterToolbar({ searchOnEnter: false });
Upvotes: 1
Views: 3276
Reputation: 221997
Probably the reason of your question is misunderstanding how the filterToolbar method work in case of datatype: 'json'
which you use. The method just set additional parameter in the postData
and initiate the grid refreshing. The information from the searching toolbar will be send to the server and the server is responsible for the data filtering. If you write that the filterToolbar not work, that the server code just ignores the filter information.
If you want that the data filtering, paging and sorting will be done by client side (the jqGrid itself) you can consider to use loadonce:true
parameter of jqGrid. In the case the server should send back not the first page of data, but the whole grid data. After the first data loading the jqGrid will change the datatype: 'json'
to datatype: 'local'
and later jqGrid will make sorting, paging and filtering of the data locally.
Upvotes: 3