I want to load a grid with default sorting on it\'s one of field. I done this by adding sortname and sortorder to my grid,but when grid is loaded sorting sign is shown on a
If you use remote datatype
(datatype: 'xml'
or datatype: 'json'
) the server is responsible for sorting of the data at the first load. If you use loadonce: true
and want to sort the data only on the client side you have to reload jqGrid directly after the first loading. The corresponding code could be about the following
loadComplete: function (data) {
var $this = $(this),
datatype = $this.getGridParam('datatype');
if (datatype === "xml" || datatype === "json") {
setTimeout(function () {
$this.trigger("reloadGrid");
}, 100);
}
}
UPDATE: Free jqGrid fork has the option forceClientSorting: true
, which can be used in combination with loadonce: true
option. The option forceClientSorting: true
force client side sorting and filtering. It makes the code described in the answer unneeded.