Product Bundles
DevCraft
All Telerik .NET and Kendo UI JavaScript components and AI Tools in one package.
Kendo UI
Bundle of AI Tools plus four JavaScript UI libraries built natively for jQuery, Angular, React and Vue.
Telerik
Build great .NET business apps
.Net Web
Cross-Platform
Desktop
Reporting and Documents
Testing & Mocking
Debugging
Build JavaScript UI
Javascript
AI for Developers & IT
Ensure AI program success
AI Coding
Additional Tools
Enhance the developer and designer experience
UI/UX Tools
Free Tools
CMS
Support
Resources
Design and Productivity Tools
Hi
How can we expand all nodes of kendo treeview in angular on the click of a button? Any help would be appreciated.
Thank You
Hello Deepali,
In order to expand all the nodes of the Kendo UI TreeView on button click, assign all the parent nodes to the expandedKeys property of the kendoTreeViewExpandable directive. For example:
<kendo-treeview [nodes]="data" [expandBy]="'text'" [(expandedKeys)]="expandedKeys" > </kendo-treeview>
public allParentNodes = []; public expandedKeys: any[] = this.allParentNodes.slice(); ngOnInit(){ this.getAllParentTextProperties(this.data); } public expandNodes() { this.expandedKeys = this.allParentNodes.slice(); } public getAllParentTextProperties(items: Array<any>){ items.forEach(i =>{ if(i.items){ this.allParentNodes.push(i.text); this.getAllParentTextProperties(i.items); } }) }
Similarly, by assigning an empty array to the expandedKeys, you can also collapse all the nodes on button click.
In this StackBlitz example, all the nodes of the TreeView can be expanded or collapsed on button click.
Regards, Hetali Progress Telerik
Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.