mvcjqgrid - jqgrid datatype:json for url request, and json response not work to populate -
i want make request (sync) server populate jqgrid. did this:
$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 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 });
the json respose of server this:
{"total":1,"page":1,"rows":[{"result":null,"test":"val"}],"records":1}
where error? thanks!
you should use jsonreader
corresponds data posted. in case of json data posted should use jsonreader: {repeatitems: false}
. many other options jsonreader
correct, root
wrong. have remove root
property jsonreader
or change root: "rows"
or root: function (obj) { return obj.rows; }
(usage of return obj;
false).
additionally recommend use loadonce: true
if server don't implemented server side paging of data. in way options gridview: true
, height: "auto"
recommended.
Comments
Post a Comment