3
我想要第一次將kendo數據源綁定到odata源碼,而沒有多少運氣。我發現了一個示例產品,它允許版本控制器看起來非常有用。該OData的輸出看起來像將Odata綁定到與Kendo Grid一起使用的KendoUI數據源
{
"d": {
"__metadata": {
"id": "http://localhost:11232/versionbyroute/v1/Products(7)",
"uri": "http://localhost:11232/versionbyroute/v1/Products(7)",
"type": "ODataVersioningSample.V1.ViewModels.Product",
"actions": {
"http://localhost:11232/versionbyroute/v1/$metadata#Container.Product": [
{
"title": "Product",
"target": "http://localhost:11232/versionbyroute/v1/Products(7)/Product"
}
]
}
},
"ID": 7,
"Name": "MS-DOS 3.0 (OEM)",
"ReleaseDate": null,
"SupportedUntil": null
}
}現在
與劍道我不太清楚我是怎麼打算訪問ID &名稱至今
var datasource = new kendo.data.DataSource({
type: "odata",
transport: {
read: {
beforeSend: function (req) {
req.setRequestHeader('Accept', 'application/json;odata=verbose');
},
url: "http://localhost:11232/versionbyroute/v1/Products(7)",
}
},
schema: {
model: {
fields: {
Name: { type: "string" }
}
}
},
pageSize: 20,
serverPaging: true,
serverFiltering: true,
serverSorting: true
});
$("#grid").kendoGrid({
height: 430,
sortable: true,
dataSource: datasource,
columns: [{ field: 'Name', title: 'Name' }]
});
我覺得我關閉,但我認爲我在設置模式的方式上做錯了什麼?任何人都可以指向正確的方向。
編輯
如果任何人是在同一條船上
$("#grid").kendoGrid({
height: 430,
sortable: true,
dataSource: {
type: "odata",
transport: {
read: {
beforeSend: function (req) {
req.setRequestHeader('Accept', 'application/json;odata=verbose');
},
url: "http://localhost:11232/versionbyroute/v1/Products",
dataType: "json"
}
},
pageSize: 20,
serverPaging: true,
serverFiltering: true,
serverSorting: true,
},
filterable: true,
pageable: true,
columns: [{ field: 'Name', title: 'Name' }]
});
我很高興你找到了解決問題的辦法。但是,最好通過實際使用下面的「發佈你的答案」部分來回答你自己的問題(即不要用答案來編輯你的問題)。這樣它不再被列爲未答覆。謝謝。 – Brett