Reputation: 3046
I have the data in the following format and when binding i get empty rows in my jqGrid
. What should be my data type or how can i avoid using jsonReader
so that it will handle it by default.
My grid structure is,
$("#UserReportGrid").jqGrid({
datatype: 'local',
data: data,
colNames: colNames,
colModel: colNames,
localReader: {
repeatitems: true,
cell: "",
id: 0, root: "data",
},
rowNum: 10,
rowList: [10, 25, 50, 100],
pager: '#GridPager',
caption: "User Details",
height: 'auto',
sortname: 'SNo',
gridview: true
});
I have tried,
JSON.parse(data) resulted in exception
JSON.parse(JSON.stringify(data)) resulted in same no records are displayed
Upvotes: 0
Views: 449
Reputation: 221997
The reason of your problem is the usage of wrong localReader
parameter. You should either replace it to
localReader: { id: "SNo" }
or to remove it at all and to add key: true
in the column SNo
, if you have the column at all in colModel
.
The exact processing of input data could be different in different versions of jqGrid and in different forks (free jqGrid, commercial Guriddo jqGrid JS and old jqGrid in version <=4.7). Please include the version of jqGrid, which you use (can use) and the information about the fork in every question about jqGrid.
Upvotes: 2