2
我正在使用jQuery的WebPart頁面上工作,我打算將jqGrid也納入到頁面中。該網頁將在grid.i加載所有列表項得到了阿賈克斯的響應,但數據不會顯示網格此選項將顯示一條消息「沒有記錄查看」無法在JqGrid中加載SharePoint列表項REST API響應
jQuery("#list2").jqGrid({
url:"https://xyz.sharepoint.com/sites/Live/_vti_bin/ListData.svc/Region",
datatype: "json",
type: "GET",
contentType: 'application/json;odata=verbose',
ajaxGridOptions: { contentType: "application/json; charset=utf-8" },
colNames:["Country", "State", "City"],
colModel:[
{name:'Country',index:'Country', width:55},
{name:'State',index:'State', width:90},
{name:'City',index:'City', width:90}
],jsonReader : {
records: "__metadata",
cell: "",
repeatitems: false
},
rowNum: 3,
gridview: true,
pager: '#pager2',
autoencode: true,
viewrecords: true,
height: "auto",
ignoreCase: true,
hidegrid: false
});
</Script>
這是JSON的我得到
{
"d" : {
"results": [
{
"__metadata": {
"uri": "https://xyz.sharepoint.com/sites/Live/_vti_bin/ListData.svc/Region(1)", "etag": "W/\"1\"", "type": "Microsoft.SharePoint.DataService.RegionItem"
}, "ContentTypeID": "0x010071297C85CCC1654A942D938B605256CA", "Country": "Australia", "State": "New South Wales", "City": "Abbotsford", "Id": 1, "ContentType": "Item", "Modified": "\/Date(1397547577000)\/", "Created": "\/Date(1397547577000)\/", "CreatedBy": {
"__deferred": {
"uri": "https://xyz.sharepoint.com/sites/Live/_vti_bin/ListData.svc/Region(1)/CreatedBy"
}
}, "CreatedById": 9, "ModifiedBy": {
"__deferred": {
"uri": "https://xyz.sharepoint.com/sites/Live/_vti_bin/ListData.svc/Region(1)/ModifiedBy"
}
}, "ModifiedById": 9, "Owshiddenversion": 1, "Version": "1.0", "Attachments": {
"__deferred": {
"uri": "https://xyz.sharepoint.com/sites/Live/_vti_bin/ListData.svc/Region(1)/Attachments"
}
}, "Path": "/sites/live/Lists/Region"
},.....
讓我知道我做錯了什麼。 任何幫助將不勝感激。謝謝。