I using jqGrid v4.4.5.When the grid is empty , show 'Page 1 of 0'.I read this answer but my problem is not solved.My httphandler send this json result
"{\"page\":0,\"records\":0,\"rows\":[],\"total\":0,\"userdata\":null}"
gridParaf = $("#gridParaf").jqGrid(
{
url:"GetLetterInformationHandler.ashx?CurrentUser=" + 1457,
datatype: 'json',
width: $("#contentParaf").width() + 410,
height: $("#contentParaf").height() - 20,
direction: "rtl",
colNames: ['IAnsDateTime', 'IAnsState'],
colModel: [
{ name: 'IAnsDateTime', width: 50, sortable: false, hidden: false, template: CenterTemplate },
{ name: 'IAnsState', width: 20, sortable: false, hidden: false, template: CenterTemplate },
],
rowNum: 20,
loadonce: true,
rowList: [5, 10, 20],
recordpos: "left",
ignoreCase: true,
toppager: true,
viewrecords: true,
sortorder: "desc",
scrollOffset: 1,
editurl: 'clientArray',
shrinkToFit: true,
jsonReader:
{
repeatitems: false,
},
gridview: true,
});
I suppose that the correct JSON response is
{"page":0,"records":0,"rows":[],"total":0,"userdata":null}
and just the debugger display you the response in the format
"{\"page\":0,\"records\":0,\"rows\":[],\"total\":0,\"userdata\":null}"
In the case you can try to use the following jsonReader
jsonReader: {
repeatitems: false,
page: function (obj) {
return obj.page !== undefined && obj.page !== 0 ? obj.page : "0";
}
}
I hope it will solve your problem. See more information in the answer.
UPDATED: Because you use loadonce: true
you should define both jsonReader
and localReader
in the same way
jsonReader: {
page: function (obj) {
return obj.page !== undefined && obj.page !== 0 ? obj.page : "0";
}
},
localReader: {
page: function (obj) {
return obj.page !== undefined && obj.page !== 0 ? obj.page : "0";
}
}
See the demo.