1
我從WebService得到Json響應如下Jqgrid沒有綁定數據
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 });