我一直在努力让这个工作好几天。
奇怪的是,我通过各种试验得到了它的工作 - 但现在它根本没有装载这是我的设置:
$("#table-Select").jqGrid({
url: 'SelectionListService.asmx/GetList',
mtype: 'POST',
datatype: 'json',
ajaxGridOptions: { contentType: 'application/json; charset=utf-8' },
postData: { SelectionType: 'Project' },
colNames: ['id', 'Title', 'DocumentID'],
colModel: [
{ name: 'id', index: 'id', width: 20,hidden: false },
{ name: 'Title', index: 'Title' ,width: 220,hidden:false},
{ name: 'DocumentID', index: 'DocumentID',width: 220, hidden: false}
],
hidegird: false,
autowidth: true,
//height: 'auto',
rowNum: 0,
rowList: [10, 20, 30],
pager: jQuery('#table-SelectPager'),
sortname: 'Title',
viewrecords: true,
loadonce: true,
sortorder: "desc",
caption: "Select Project",
//fixes Invalid JSON Primitive error
serializeGridData: function (postData) {
if (postData.searchField === undefined) postData.searchField = null;
if (postData.searchString === undefined) postData.searchString = null;
if (postData.searchOper === undefined) postData.searchOper = null;
//if (postData.filters === undefined) postData.filters = null;
return JSON.stringify(postData);
},
jsonReader: {
root: "rows",
page: "page",
total: "total",
records: "records"
}
}).navGrid('#table-SelectPager', { edit: false, add: false, del: false });
以下是来自WebService调用的JSON数据:
{"d":{"__type":"NCR.SelectionListService+JQGrid","page":1,"total":4,"records":4,"rows":[{"id":"1","DocumentID":"pgmprj://aecomme/newdohaportproject/envcomp","Title":"NDPP-Environmental Compliance Monitoring"},{"id":"2","DocumentID":"pgmprj://aecomme/newdohaportproject/ndpp-portbasinandinnerbreakwatersconstruction","Title":"NDPP-Port Basin and Inner Breakwaters Construction"},{"id":"3","DocumentID":"pgmprj://aecomme/newdohaportproject/ndpp-programmanagement","Title":"NDPP-Program Management"},{"id":"4","DocumentID":"pgmprj://aecomme/newdohaportproject/ndpp-supplementarysiteinvestigation","Title":"NDPP-Supplementary Site Investigation"}]}}
我知道它一定是我想念的简单 - 但在我看过的所有例子之后 - 我不知道我错过了什么。
任何想法都会非常感激。
答案 0 :(得分:0)
您应该将jsonReader
选项修改为以下内容:
jsonReader: {
root: "d.rows",
page: "d.page",
total: "d.total",
records: "d.records",
repeatitems: false
}
请参阅the demo。