I'm having trouble sorting jqGrid. I would prefer to do this sorting on the client, but I also want to make a new call to the database to get the sorted results.
I can click on the column headings and the sorting arrows sort, but the data does not change at all.
I looked through this question , however the reloadGrid call did not seem to help.
My whole grid looks like this:
var x = $("#grid").jqGrid({
jsonReader: { root: "rows", repeatitems: false },
datatype: "json",
height: 'auto',
autowidth: true,
forceFit: true,
colNames:['ID','Name'],
colModel:[
{name:'id', key:true, index:'id', width:60, sorttype:"int", jsonmap:"id"},
{name:'name', index:'name', width:90, jsonmap: "name"}
],
caption: "Results",
loadonce: true,
sortable: true,
loadComplete: function() {
jQuery("#grid").trigger("reloadGrid");
}
});
var jsonData = [
{id: 1, name: 'Apple'},
{id: 2, name: 'Banana'},
{id: 3, name: 'Pear'},
{id: 4, name: 'Orange'}
];
x[0].addJSONData( { rows: jsonData } );