This is a migrated thread and some comments may be shown as answers.

TreeList expand API

2 Answers 653 Views
TreeList
This is a migrated thread and some comments may be shown as answers.
ICT
Top achievements
Rank 1
Iron
ICT asked on 08 Feb 2021, 04:34 PM

Hello, 

I need to programmatically expand and collapse a row (maybe by id). Can it be done somehow?

Also is it possible to expand and collapse the tree completely programmatically?

 

Thanks,

B

2 Answers, 1 is accepted

Sort by
1
Dimiter Topalov
Telerik team
answered on 10 Feb 2021, 08:51 AM

Hi B,

The TreeList expanded items can be controlled programmatically by binding the expandedKeys option to a custom collection that can be further modified:

https://www.telerik.com/kendo-angular-ui/components/treelist/expanded-state/#toc-setting-the-expanded-items

To expand all items by default, use the initiallyExpanded option:

https://www.telerik.com/kendo-angular-ui/components/treelist/expanded-state/#toc-initially-expanded

To expand/collapse all items programmatically, for example via custom button clicks, use the first approach (expandedKeys) and set the collection to an empty array to collapse all items, and to an array, containing all items IDs (or other custom identifier property).

Here is an example, demonstrating the described approach:

https://stackblitz.com/edit/angular-khkhp1?file=app/app.component.ts

I hope this helps.

Regards,
Dimiter Topalov
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

0
ICT
Top achievements
Rank 1
Iron
answered on 10 Feb 2021, 01:42 PM

Thanks Dimiter, i reached my goal! 

Thanks a lot!

B

Tags
TreeList
Asked by
ICT
Top achievements
Rank 1
Iron
Answers by
Dimiter Topalov
Telerik team
ICT
Top achievements
Rank 1
Iron
Share this question
or