Hi Guys,
I am having a bit of trouble binding the treeview to some JSON returned by a REST datasource. The JSON looks like this:
{
"Links": {
},
"Items": [
{
"WebId": "E0PDGvCF_JoUerHmn03UKDRg4BjcATte5RGJsgBQVrI8IgR0xPQkFMIEFGIEFDQ0VQVEFOQ0UgRU5WSVJPTk1FTlRcU0hFTExcR0FTMQ",
"Id": "01dc18e0-5e3b-11e5-89b2-005056b23c22",
"Name": "Gas1",
"Description": "",
"Path": "\\\\Global AF Acceptance Environment\\Company\\Gas1",
"TemplateName": "Gas",
"CategoryNames": [],
"Links": {
"Attributes": "https://DEVSEAT/piwebapi/elements/E0PDGvCF_JoUerHmn03UKDRg4BjcATte5RGJsgBQVrI8IgR0xPQkFMIEFGIEFDQ0VQVEFOQ0UgRU5WSVJPTk1FTlRcU0hFTExcR0FTMQ/attributes",
"Categories": "https://DEVSEAT/piwebapi/elements/E0PDGvCF_JoUerHmn03UKDRg4BjcATte5RGJsgBQVrI8IgR0xPQkFMIEFGIEFDQ0VQVEFOQ0UgRU5WSVJPTk1FTlRcU0hFTExcR0FTMQ/categories",
"EventFrames": "https://DEVSEAT/piwebapi/elements/E0PDGvCF_JoUerHmn03UKDRg4BjcATte5RGJsgBQVrI8IgR0xPQkFMIEFGIEFDQ0VQVEFOQ0UgRU5WSVJPTk1FTlRcU0hFTExcR0FTMQ/eventframes",
"InterpolatedData": "https://DEVSEAT/piwebapi/streamsets/E0PDGvCF_JoUerHmn03UKDRg4BjcATte5RGJsgBQVrI8IgR0xPQkFMIEFGIEFDQ0VQVEFOQ0UgRU5WSVJPTk1FTlRcU0hFTExcR0FTMQ/interpolated",
"RecordedData": "https://DEVSEAT/piwebapi/streamsets/E0PDGvCF_JoUerHmn03UKDRg4BjcATte5RGJsgBQVrI8IgR0xPQkFMIEFGIEFDQ0VQVEFOQ0UgRU5WSVJPTk1FTlRcU0hFTExcR0FTMQ/recorded",
"SummaryData": "https://DEVSEAT/piwebapi/streamsets/E0PDGvCF_JoUerHmn03UKDRg4BjcATte5RGJsgBQVrI8IgR0xPQkFMIEFGIEFDQ0VQVEFOQ0UgRU5WSVJPTk1FTlRcU0hFTExcR0FTMQ/summary",
}
},
{
"WebId": "E0PDGvCF_JoUerHmn03UKDRgoJxXIDte5RGJsgBQVrI8IgR0xPQkFMIEFGIEFDQ0VQVEFOQ0UgRU5WSVJPTk1FTlRcU0hFTExcR0FTMg",
"Id": "20579ca0-5e3b-11e5-89b2-005056b23c22",
"Name": "Gas2",
"Description": "",
"Path": "\\\\Global AF Acceptance Environment\\Company\\Gas2",
"TemplateName": "Gas",
"CategoryNames": [],
"Links": {
"Attributes": "https://DEVSEAT/piwebapi/elements/E0PDGvCF_JoUerHmn03UKDRgoJxXIDte5RGJsgBQVrI8IgR0xPQkFMIEFGIEFDQ0VQVEFOQ0UgRU5WSVJPTk1FTlRcU0hFTExcR0FTMg/attributes",
"Categories": "https://DEVSEAT/piwebapi/elements/E0PDGvCF_JoUerHmn03UKDRgoJxXIDte5RGJsgBQVrI8IgR0xPQkFMIEFGIEFDQ0VQVEFOQ0UgRU5WSVJPTk1FTlRcU0hFTExcR0FTMg/categories",
"EventFrames": "https://DEVSEAT/piwebapi/elements/E0PDGvCF_JoUerHmn03UKDRgoJxXIDte5RGJsgBQVrI8IgR0xPQkFMIEFGIEFDQ0VQVEFOQ0UgRU5WSVJPTk1FTlRcU0hFTExcR0FTMg/eventframes",
"InterpolatedData": "https://DEVSEAT/piwebapi/streamsets/E0PDGvCF_JoUerHmn03UKDRgoJxXIDte5RGJsgBQVrI8IgR0xPQkFMIEFGIEFDQ0VQVEFOQ0UgRU5WSVJPTk1FTlRcU0hFTExcR0FTMg/interpolated",
"RecordedData": "https://DEVSEAT/piwebapi/streamsets/E0PDGvCF_JoUerHmn03UKDRgoJxXIDte5RGJsgBQVrI8IgR0xPQkFMIEFGIEFDQ0VQVEFOQ0UgRU5WSVJPTk1FTlRcU0hFTExcR0FTMg/recorded",
"SummaryData": "https://DEVSEAT/piwebapi/streamsets/E0PDGvCF_JoUerHmn03UKDRgoJxXIDte5RGJsgBQVrI8IgR0xPQkFMIEFGIEFDQ0VQVEFOQ0UgRU5WSVJPTk1FTlRcU0hFTExcR0FTMg/summary",
}
},
{
"WebId": "E0PDGvCF_JoUerHmn03UKDRg_fTxOXkq5RGHhgBQVrI8IgR0xPQkFMIEFGIEFDQ0VQVEFOQ0UgRU5WSVJPTk1FTlRcU0hFTExcUk9PVCBET1dOU1RSRUFN",
"Id": "39f1f4fd-2a79-11e5-8786-005056b23c22",
"Name": "Root Downstream",
"Description": "",
"Path": "\\\\Global AF Acceptance Environment\\Company\\Root Downstream",
"TemplateName": "",
"CategoryNames": [],
"Links": {
"InterpolatedData": "https://DEVSEAT/piwebapi/streamsets/E0PDGvCF_JoUerHmn03UKDRg_fTxOXkq5RGHhgBQVrI8IgR0xPQkFMIEFGIEFDQ0VQVEFOQ0UgRU5WSVJPTk1FTlRcU0hFTExcUk9PVCBET1dOU1RSRUFN/interpolated",
"RecordedData": "https://DEVSEAT/piwebapi/streamsets/E0PDGvCF_JoUerHmn03UKDRg_fTxOXkq5RGHhgBQVrI8IgR0xPQkFMIEFGIEFDQ0VQVEFOQ0UgRU5WSVJPTk1FTlRcU0hFTExcUk9PVCBET1dOU1RSRUFN/recorded",
"SummaryData": "https://DEVSEAT/piwebapi/streamsets/E0PDGvCF_JoUerHmn03UKDRg_fTxOXkq5RGHhgBQVrI8IgR0xPQkFMIEFGIEFDQ0VQVEFOQ0UgRU5WSVJPTk1FTlRcU0hFTExcUk9PVCBET1dOU1RSRUFN/summary",
}
},
{
"WebId": "E0PDGvCF_JoUerHmn03UKDRgThKq6zpe5RGJsgBQVrI8IgR0xPQkFMIEFGIEFDQ0VQVEFOQ0UgRU5WSVJPTk1FTlRcU0hFTExcV0FURVIgSU5KRUNUT1Iy",
"Id": "ebaa124e-5e3a-11e5-89b2-005056b23c22",
"Name": "Water Injector2",
"Description": "",
"Path": "\\\\Global AF Acceptance Environment\\Company\\Water Injector2",
"TemplateName": "Water Injector",
"CategoryNames": [],
"Links": {
"InterpolatedData": "https://DEVSEAT/piwebapi/streamsets/E0PDGvCF_JoUerHmn03UKDRgThKq6zpe5RGJsgBQVrI8IgR0xPQkFMIEFGIEFDQ0VQVEFOQ0UgRU5WSVJPTk1FTlRcU0hFTExcV0FURVIgSU5KRUNUT1Iy/interpolated",
"RecordedData": "https://DEVSEAT/piwebapi/streamsets/E0PDGvCF_JoUerHmn03UKDRgThKq6zpe5RGJsgBQVrI8IgR0xPQkFMIEFGIEFDQ0VQVEFOQ0UgRU5WSVJPTk1FTlRcU0hFTExcV0FURVIgSU5KRUNUT1Iy/recorded",
"SummaryData": "https://DEVSEAT/piwebapi/streamsets/E0PDGvCF_JoUerHmn03UKDRgThKq6zpe5RGJsgBQVrI8IgR0xPQkFMIEFGIEFDQ0VQVEFOQ0UgRU5WSVJPTk1FTlRcU0hFTExcV0FURVIgSU5KRUNUT1Iy/summary",
}
}
]
}
But I don't know how to adapt the Treeview example to show the "Name" as the labels in the treeview and bind to the hierarchical data source. Do I need to use the Datasource.Parse functionality to extract the "Items" to kind of flatten the JSON? Many thanks for any suggestions.
<body>
<a class=
"offline-button"
href=
"../index.html"
>Back</a>
<div id=
"example"
>
<div class=
"demo-section k-header"
>
<div id=
"treeview"
></div>
</div>
<script>
var
serviceRoot =
"https://DEVSEAT/piwebapi/assetdatabases/D0PDGvCF_JoUerHmn03UKDRgdnjerQmIrk-WsTnT_VuIGAR0xPQkFMIEFGIEFDQ0VQVEFOQ0UgRU5WSVJPTk1FTlRcU0hFTEw"
;
homogeneous =
new
kendo.data.HierarchicalDataSource({
transport: {
read: {
url: serviceRoot +
"/Elements"
,
dataType:
"jsonp"
}
},
schema: {
model: {
id:
"WebID"
,
hasChildren:
"Links"
}
}
});
$(
"#treeview"
).kendoTreeView({
dataSource: homogeneous,
dataTextField:
"Name"
});
</script>
</div>
</body>