Kendo ui 将Odata绑定到KendoUI数据源以用于Kendo网格
我第一次尝试将剑道数据源绑定到odata源,但运气不太好。我发现了一个示例产品,它允许对odata控制器进行版本控制,这看起来非常有用。odata输出看起来像Kendo ui 将Odata绑定到KendoUI数据源以用于Kendo网格,kendo-ui,odata,Kendo Ui,Odata,我第一次尝试将剑道数据源绑定到odata源,但运气不太好。我发现了一个示例产品,它允许对odata控制器进行版本控制,这看起来非常有用。odata输出看起来像 { "d": { "__metadata": { "id": "http://localhost:11232/versionbyroute/v1/Products(7)", "uri": "http://localhost:11232/versionbyroute/v1/Products(7)",
{
"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' }]
});
$("#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' }]
});
提交人答复: 如果其他人也在同一条船上
$("#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' }]
});
$("#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' }]
});
我很高兴你找到了解决问题的办法。但是,最好通过实际使用下面的“发布您的答案”部分来回答您自己的问题(即不使用答案编辑您的问题)。这样,它就不再被列为未答复。谢谢,这对我有帮助。事实上,如果你解释了这个解决方案会更好,但它只是一个插曲,所以。。。谢谢