【发布时间】:2018-05-28 10:42:09
【问题描述】:
好的。我在这里经历了很多答案,但没有一个有效。我想做的是在jqgrid 中显示我的JSON 回复。但它显示了这个错误:
错误:
这是代码:
var cols = ['VNo', 'Notes', 'Title'];
var colmodel = [
{ key: true, hidden: false, name: 'VNo', index: 'VNo' },
{ key: false, hidden: false, name: 'Notes', index: 'Notes' },
{ key: false, hidden: false, name: 'Title', index: 'Title' }
];
alert(colmodel.length);
$('#grid').jqGrid({
url: "/Voucher/GetJournalVouchers",
datatype: 'json',
mtype: "GET",
colNames:cols,
ColModel:colmodel,
pager: jQuery('#pager'),
rowNum: 10,
rowList: [10, 20, 30, 40],
height: '100%',
viewreocrds: true,
caption: 'Vouchers',
emptyrecords: 'No records to display',
jsonReader: {
root: "rows",
page: "page",
total: "total",
records: "records",
repeatitems: false,
id: "0"
},
autowidth: true,
multiselect: false,
});
如果我删除 colNames,它会显示 jqGrid,但不会加载任何数据。这是我在删除 colNames 后收到的JSON 响应:
【问题讨论】:
-
数据中的列名 TransId 与您在网格中声明的任何内容都不对应
-
每一列都要声明吗?
-
没有线索,但那是一回事
-
试过但结果相同
-
ColModel 应该是 colModel