当我打电话getrowdata()我收到此错误$ tpcolModel [i]于grid.base.js未定义
jQuery(jqgrid).jqGrid({
url: url,
datatype: 'json',
mtype: 'GET',
colNames: ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I'],
colModel: [{ name: 'A', index: 'A', width: 50, align: 'right', sortable: true, resizable: false },
{ name: 'B', index: 'B', width: 50, align: 'right', sortable: true, sorttype: 'int', title: false, resizable: false },
{ name: 'C', index: 'C', width: 50, align: 'right', sortable: true, sorttype: 'int', resizable: false },
{ name: 'D', index: 'D', width: 40, align: 'right', sortable: true, sorttype: 'int', title: false, resizable: false },
{ name: 'E', index: 'E', width: 75, align: 'right', sortable: true, sorttype: 'float', resizable: false },
{ name: 'F', index: 'F', width: 75, sortable: true, datefmt: ' M d, y H:i:s', resizable: false },
{ name: 'G', index: 'G', width: 75, sortable: true, datefmt: ' M d, y H:i:s', resizable: false },
{ name: 'H', index: 'H', width: 500, sortable: true, sorttype: 'text', resizable: false },
{ name: 'I', index: 'I', width: 300, sortable: true, sorttype: 'text', resizable: false}],
jsonReader: {
root: "A",
page: "page",
total: "total",
records: "records",
repeatitems: false
}
});
jsondata格式
{ "total":"4",
"page":"1",
"records":"35",
"A":[{
"A":"01.000",
"B":"01.000",
"C":"01.000",
"D":"1",
"E":"1.075",
"F":" 19:17:09",
"G":" 11 19:17:09",
"H":"dfsd",
"I":""}]}
收到错误:$t.p.colModel[i] is undefined in grid.base.js(line 2470)
这个问题是json响应中有一些html字符,Jqgrid无法正确处理这些字符。现在我正在对字符进行html化,并且它工作正常。 – Sandy
@Sandy:JSON响应可以包含*任何UNICODE字符*。 **只有两个字符''''和'\\'必须转义**(见[这里](http://www.json.org/)),并且可能会有更多字符*被转义。 JSON数据[here](http://jsonlint.com/)。在我发布我的答案之前,我对[此演示]进行了验证(http://www.ok-soft-gmbh.com/jqGrid/Sandy。 htm),它使用你原来的*发布的JSON数据,所以如果你仍然有任何问题,原因应该在其他地方 – Oleg
感谢您的回复。问题出在我的代码中。它是固定的 – Sandy