我一直有問題讓jqGrid排序。我希望在客戶端進行這種排序,但我也願意對數據庫進行新的調用以獲得排序結果。排序不能和jqGrid一起工作
我可以點擊列標題,排序箭頭改變方向,但是數據根本不會改變。
我看過this question,但調用reloadGrid似乎沒有幫助。
我的整個網格如下:
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"); // Call to fix client-side sorting
}
});
//This data comes from a web service call, hard coding in to test
var jsonData = [
{id: 1, name: 'Apple'},
{id: 2, name: 'Banana'},
{id: 3, name: 'Pear'},
{id: 4, name: 'Orange'}
];
x[0].addJSONData({ rows: jsonData });
http://www.trirand.com/blog/?page_id=393/help/loading-json-data-techniques-and-sorting-issue/ – 2012-04-23 19:45:09