Hello,
I've been struggeling for sometime to figure out how to do this. I have a list of checkedKeys, and I must open the treeview with all the parent nodes for each id expanded.
This is my treeview element :
<kendo-treeview
style="max-height: 400px; height: 400px"
[nodes]="parsedData"
textField="name"
[children]="children"
[hasChildren]="hasChildren"
[(checkedKeys)]="checkedKeys"
[kendoTreeViewCheckable]="checkableSettings"
kendoTreeViewExpandable
kendoTreeViewCheckable
[animate]="false"
[(expandedKeys)]="expandedKeys"
[expandBy]="'id'"
[checkBy]="'id'"
[isChecked]="isItemChecked"
></kendo-treeview>
And on the ngOnInit I call this
this.parsedData.forEach(mt => { this.setExpandedNodes(mt); });
And finally this is the setExpandedNodes function:
setExpandedNodes(node: PropertyNode) { if (node.children) { node.children.forEach(el => { if (el.children && el.children.length > 0) { el.children.forEach(chld => { if (this.checkedKeys.includes(chld.id)) { this.expandedKeys.push(el.id); console.log('Pushed to expanded keys', el); } this.setExpandedNodes(chld); }); } }); } }
Anybody know how can I achieve this?
Thanks for the help.