我正在使用 asmx 服务返回数据以在 jqGrid 中显示。我可以看到在完整回调中返回了 json 数据。这就是完整回调中的 json 数据的样子{"d":[{"__type":"HHSC.CTF.Business.BatchReceiptModel","BReceiptId"....
。我不确定为什么它前面d:
还有数据的类型名称。这是我的 jqGrid 设置看起来像
$("#list").jqGrid({
url: "../../WebServices/BatchReceiptsWebService.asmx/BatchReceiptsTable",
datatype: "json",
mtype: 'POST',
ajaxGridOptions: { contentType: 'application/json; charset=utf-8',
success: function (data, status) {
},
complete: function (xhr) {
},
error: function (jqXHR, textStatus, errorThrown) {
}
},
serializeGridData: function (postData) {
return JSON.stringify(postData);
},
jsonReader: {
repeatitems: false,
id: "BReceiptId",
page: function (obj) { return 1; },
total: function (obj) { return 1; },
root: function (obj) { return obj; },
records: function (obj) {
return obj.d.length;
}
},
colNames: ['BReceiptId', 'ReceiptNumber', 'ReceiptAmount'],
colModel: [
{ name: 'BReceiptId', index: 'BReceiptIdnId', width: 100 },
{ name: 'ReceiptNumber', index: 'ReceiptNumber', width: 150 },
{ name: 'ReceiptAmount', index: 'ReceiptAmount', align: 'right', width: 100 }
],
rowNum: 10,
loadonce: true,
gridview: true,
rownumbers: true,
rowList: [10, 20, 30],
viewrecords: true
});