Reputation: 1466
I have a kenodui treeview that I am trying to expand the top level nodes if they have the following values: "Active" or "Closed", the remaining nodes can remain closed. I am using the following code to create my treeview:
if (CI.Popup.treeview == null) {
CI.Popup.treeview = $("#RelatedPropertyListing").kendoTreeView({
template: "#= item.Name #",
dataImageUrlField: "image",
dataSource: CI.Popup.treeDS,
dataTextField: ["Name", "Name"],
encoded: true
}).data("kendoTreeView");
}
My datasource is defined as a json kendo.data.HierarchicalDataSource
. I have tried generating the treeview using html instead of a datasource but it was unbareably slow so I have to use this method.
Any ideas how I can expand only those nodes that have a value of "Active" or "Closed"???
Thanks in advance for any help.
Upvotes: 0
Views: 780
Reputation: 40887
If you can slightly change your returned data, you can set expanded
to true
for each node that you want expanded and KendoUI will automatically take care of it.
Example:
var data = [
{
text : "node 1",
expanded: true,
items : [
{ text: "node 1.1" },
{
text : "node 1.2",
expanded: false,
items : [
{ text: "node 1.2.1" },
{ text: "node 1.2.2" },
{ text: "node 1.2.3" }
]
},
{ text: "node 1.3" }
]
}
];
var treeview = $("#treeview-left").kendoTreeView({
dataSource : data,
loadOnDemand: true
}).data("kendoTreeView");
JSFiddle in here
Upvotes: 1