本文介绍了如何使用嵌套的Json填充Kendo UI网格?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 29岁程序员,3月因学历无情被辞! 如何使用嵌套的JSON填充Kendo UI网格。How can I populate Kendo UI grid with nested JSON.我的意思是我的JSON就像I mean my JSON is likevar myJson: [{"oneType":[ {"id":1,"name":"John Doe"}, {"id":2,"name":"Don Joeh"} ]}, {"othertype":"working"}, {"otherstuff":"xyz"}]}];我希望Kendo UI Grid的列为Id,Name,OtherType和OtherStuff。and I want Kendo UI Grid with columns as Id, Name, OtherType and OtherStuff.提前致谢。推荐答案对于复杂的JSON结构,您可以使用 schema.parseFor complex JSON structures, you might use schema.parsevar 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略微更改为:If you slightly change your JSON to:{ "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"); 这篇关于如何使用嵌套的Json填充Kendo UI网格?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云! 08-15 20:51