对于复杂的JSON结构,您可以使用
schema.parse
var grid = $("#grid").kendoGrid({ dataSource : { data: [ { "oneType": [ {"id": 1, "name": "John Doe"}, {"id": 2, "name": "Don Joeh"} ] }, {"othertype": "working"}, {"otherstuff": "xyz"} ], pageSize: 10, schema : { parse : function(d) { for (var i = 0; i < d.length; i++) { if (d[i].oneType) { return d[i].oneType; } } return []; } } }}).data("kendoGrid");
如果您将JSON稍微更改为:
{ "oneType" : [ {"id": 1, "name": "John Doe"}, {"id": 2, "name": "Don Joeh"} ], "othertype" : "working", "otherstuff": "xyz"}
那么您可以使用:
var grid = $("#grid").kendoGrid({ dataSource: { data: { "oneType" : [ {"id": 1, "name": "John Doe"}, {"id": 2, "name": "Don Joeh"} ], "othertype" : "working", "otherstuff": "xyz" }, pageSize: 10, schema : { data: "oneType" } }}).data("kendoGrid");
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)