I have a grid with the following definition. Everything is working fine with the grid as is.
$("#grid").jqGrid({
url:'report_data.php',
datatype: 'json',
mtype: 'POST',
colNames:['Type','Term','Number','Visits','Calls','Unique','Avg. Duration',
'Conversion Rate'],
colModel :[{"index":"keyword_type","name":"Type","width":90},
{"index":"keyword","name":"Term","width":170},
{"index":"phone_number","name":"Number","width":100},
{"index":"visits","name":"Visits","width":80},
{"index":"calls","name":"Calls","width":70},
{"index":"unique_calls","name":"Unique","width":70},
{"index":"avg_duration","name":"Avg. Duration"},
{"index":"conversion_rate","name":"Conversion Rate","width":80}],
rowNum:100,
rowList:[25,50,100,200,500],
sortname: 'keyword_type',
sortorder: 'desc',
viewrecords: true,
height: '470px',
width: 'auto',
loadui: 'block',
postData: {"keyword_set":"140","display_type":"direct"}
});
There are links on the page to filter the grid. When the user clicks a link I set some grid params and reload the grid using:
var param_string = "filter=keyword&type=ppc";
$('#grid').setGridParam({url:'report_data.php',
postData:param_string}).trigger("reloadGrid");
The grid reloads fine with the new data, however, the columns are no longer sortable. I can see the data getting sent to the server but it no longer includes the ‘sidx’ or ‘sord’ parameters. Sorting worked fine before triggering the reload.
Any ideas on how to get the sort parameters passed again after reloading the grid?
Thanks,
Dan
You should use another syntax for the
postDataparameter:Your current syntax
postData:"filter=keyword&type=ppc"overwrite all other parameters (page,rows,sidx,sordand so on) and the server can not make correct sorting of the data.