我想向服务器发出请求(同步)以填充 jqGrid。我这样做了:
$table.jqGrid({
datatype: "json",
url:'takepage/page=1',
mtype: 'GET',
ajaxSubgridOptions: { async: false },
colNames:['Result','Test'],
colModel:[ {name:'result',index:'result',width:120},
{name:'test',index:'test', width:120}
],
pager: "#"+pager,
caption: "TESTjqGrid sync request to server",
jsonReader: {
repeatitems: false,
page: function(obj) {
return obj.page;
},
total: function(obj) {
return obj.total;
},
root: function (obj) {
console.log(obj);
return obj;
},
records: function (obj) {
console.log(obj.rows.length);
return obj.rows.length;
}
}
}).jqGrid('navGrid', "#"+pager, {
add: false,
edit: false,
del: false,
search: false,
refresh:false
});
服务器的json响应是这样的:
{"total":1,"page":1,"rows":[{"result":null,"test":"val"}],"records":1}
错误在哪里?谢谢!