【发布时间】:2015-01-02 10:00:56
【问题描述】:
我正在从 WebService 获得 Json 响应,如下所示
Json 完美返回数据。数据看起来像
{"d":"[{\"ID\":2,\"Code\":\"mycode\",\"Name\":\"Myname\",\"PassWord\":\ "A\",\"ClientLevel\":0,\"DeptNo\":\"\",\"DeptName\":\"\"},{\"ID\":3,\"Code\" :\"mycode\",\"Name\":\"ly1\",\"PassWord\":\"mypassword\", .......但不绑定我的jqgrid。
我有以下 Jqgrid 代码
jQuery("#list2").jqGrid({
mtype: 'POST',
url: "myservice.asmx/GetQueryInfo",
serializeGridData: function (postData) {
return JSON.stringify({
TableNames: TableName,
ColumnList: ColumnNames
});
},
ajaxGridOptions: { contentType: "application/json; charset=utf-8" },
jsonReader: {
repeatitems: false,
root: 'd',
page: function (obj) { return 1; },
total: function (obj) { return 1; },
records: function (obj) { return obj.toString().length; }
},
datatype: 'json',
colNames: ['ID', 'Code', 'Name', 'PassWord', 'ClientLevel', 'DeptNo', 'DeptName'],
colModel: [
{ name: "ID", width: 55 },
{ name: "Code", width: 90 },
{ name: "Name", width: 100 },
{ name: "PassWord", width: 80 },
{ name: "ClientLevel", width: 80 },
{ name: "DeptNo", width: 80 },
{ name: "DeptName", width: 150 }
],
autoencode: true,
gridview: true,
rowNum: 10,
loadonce: true,
rowList: [10, 20, 30],
pager: '#pager2',
sortname: 'ID',
viewrecords: true,
sortorder: "ID",
caption: "JSON Example",
loadError: function (jqXHR, textStatus, errorThrown) {
alert('HTTP status code: ' + jqXHR.status + '\n' +
'textStatus: ' + textStatus + '\n' +
'errorThrown: ' + errorThrown);
alert('HTTP message body (jqXHR.responseText): ' + '\n' + jqXHR.responseText);
}
});
jQuery("#list2").jqGrid('navGrid', '#pager2', { edit: false, add: false, del: false });
【问题讨论】:
标签: c# asp.net json web-services jqgrid