不确定我是否错过了一个选项,但我无法使用以下代码对我的 jqGrid 进行排序。我的网格只有一列,我试图使其可排序:
$('#jqgrid').jqGrid({
url: contextPath + '/js/jqgrid-data.json',
datatype: 'json',
colNames: ['Destination Name'],
colModel: [
{ name: 'DestName',
sortable: true,
sorttype: 'text',
index: 'DestName'
}
],
sortname: 'DestName',
sortorder: 'asc',
jsonReader: { repeatitems: false },
height: 'auto',
width: 600,
onSelectRow: function(id){
alert('Selected row ID ' + id);
}
});
来自服务器的数据如下所示:
{
"total": 1,
"page": 1,
"records": 10,
"rows": [
{
"id": "1",
"DestName": "Administration Office"
},
{
"id": "2",
"DestName": "Business Office"
}
....
}
想法?