次のデータがあります。
[
{"id":1,"parendId":0,"name":"Foods","hasItems":"true},
{"id":2,"parentId":1,"name":"Fruits","hasItems":"true"},
{"id":3,"parentId":1,"name":"Vegetables","hasItems":"true"},
{"id":4,"parentId":2,"name":"apple","hasItems":"false"},
{"id":5,"parentId":2,"name":"orange","hasItems":"true"},
{"id":6,"parentId":3,"name":"tomato","hasItems":"true"},
{"id":7,"parentId":3,"name":"carrot","hasItems":"true"},
{"id":8,"parentId":3,"name":"cabbage","hasItems":"true"},
{"id":9,"parentId":3,"name":"potato","hasItems":"true"},
{"id":10,"parentId":3,"name":"lettuce","hasItems":"false"}
]
上記のデータの kendo ui ツリービューを構成する方法を誰か教えてもらえますか? また、剣道UIドロップダウンリスト内にこのツリービューを表示することは可能ですか?
アップデート:
これは私がこれまでに持っているものです...
categories = new kendo.data.HierarchicalDataSource({
transport: {
read: {
url: UrlThatFetchesData
}
},
schema: {
model: {
id: 'id',
parentId: 'parentId',
name: 'name'
}
}
});
$('#tvCategories').kendoTreeView({
dataSource: categories,
dataTextField: 'name',
dataValueField: 'id'
});
すべての項目がメイン カテゴリとして表示され、その下に 1 つずつ表示されます。ツリービューでparentIdを使用するにはどうすればよいですか?