admin管理员组文章数量:1425964
Let´s say I have the following JSON data, which is the response data of an HTTP service call...
{
[ "container" : [
{
"category" : "default",
"items" : [
{ "name" : "item-1" },
{ "name" : "item-2" }
]
} ]
]
}
I want to bind the items
array to the Kendo UI Grid, so I defined the following data source...
var dataSource = new kendo.data.DataSource({
transport: {
read: {
url: "http://...",
dataType: "jsonp",
data: {
Accept: "application/json"
}
}
},
schema: {
model: ???
}
});
I´ve absolutely no clue how to define the model schema because I couldn´t find any information on that particular binding scenario in the documentation.
Let´s say I have the following JSON data, which is the response data of an HTTP service call...
{
[ "container" : [
{
"category" : "default",
"items" : [
{ "name" : "item-1" },
{ "name" : "item-2" }
]
} ]
]
}
I want to bind the items
array to the Kendo UI Grid, so I defined the following data source...
var dataSource = new kendo.data.DataSource({
transport: {
read: {
url: "http://...",
dataType: "jsonp",
data: {
Accept: "application/json"
}
}
},
schema: {
model: ???
}
});
I´ve absolutely no clue how to define the model schema because I couldn´t find any information on that particular binding scenario in the documentation.
Share Improve this question edited Jul 23, 2013 at 18:52 Matze asked Jul 23, 2013 at 17:23 MatzeMatze 5,5287 gold badges50 silver badges69 bronze badges2 Answers
Reset to default 3In the response, you have defined container
as an array
but not sure if it might repeat. As far as I understand the actual data is items
. Correct? If so, this is the minimum DataSource definition.
var dataSource = new kendo.data.DataSource({
transport: {
read: {
url : "http://...",
dataType: "json",
data: {
Accept: "application/json"
}
}
},
pageSize : 10,
schema : {
data: "container[0].items"
}
});
NOTE: The response that you show doesn't look like a JSONP but a JSON. That's why I'm setting dataType
as JSON.
Take a look at the example here which has what I think you are looking for.
本文标签: javascriptHow to bind JSON child array to Kendo gridStack Overflow
版权声明:本文标题:javascript - How to bind JSON child array to Kendo grid - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745395804a2656806.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论