Declined
Last Updated: 24 Aug 2022 15:13 by ADMIN
Matt
Created on: 18 Aug 2022 01:07
Category: TreeList
Type: Feature Request
0
Bindable way to set expanded items for TreeList

From what I can see, currently the only way to set the expanded items for a TreeList is through the state.

The main problem is that the state doesn't fire the OnExpand event, meaning that if you have a server loaded tree you need to make sure to load the data before each item is expanded. It also allows for duplicates in the 'ExpandedItems' if you don't check for duplicates before adding to it.

The TreeView has an 'ExpandedItems' parameter that can be bound which is a bit nicer than using the state, but from my quick test this also doesn't fire the OnExpand event.

 

My request is for one of the following to be added:

  1. Similar to how you can set the 'HasChildrenField' or 'ItemsField' on the TreeList, allow a 'IsExpandedField' value to be bound (Should fire the OnExpand when changed if possible). This would be the simplest way allow bindable control over the expansion of items while also making it so we don't have to manage duplicates in the 'ExpandedItems' collection.
  2. Expose a method to expand/unexpand rows. This would be different to manually changing the state as it would also fire the OnExpand event for each row expanded.
  3. Similar to the TreeView, allow an 'ExpandedItems' to be bound. Preferably this would also fire the OnExpand event.
1 comment
ADMIN
Nadezhda Tacheva
Posted on: 24 Aug 2022 15:13

Hi Matt,

I'd like to first share some details on the concept of the TreeList events. Generally, the events that the component exposes are triggered upon user action. The idea is to notify you that the user performed this specific action, so you can react to it. Conceptually, if such action is programmatically invoked, you would already be aware of it, so you would not need an additional notification. We are currently discussing the OnExpand event but the case will be the same with the OnCollapse, SelectedItemsChanged, PageChanged or other events - they will only fire when the user makes the corresponding action.

The same behavior can be observed in the TreeView as you already noticed  - programmatically changing the ExpandedItems will not fire the OnExpand event and this is expected as described above. The TreeView, however, does not have state, so the only option to programmatically modify the ExpandedItems is through the parameter. The TreeList, on another hand, allows such modification through its state.

Having the above in mind, I will hereby mark the request as "Declined" and I will share my suggestion how to handle the scenario. Since the OnExpand is essentially not expected to fire after you internally modify the ExpandedItems, this will make it not suitable event to load the data in. You can, however, perform that in the event you are actually changing the TreeList state in.

I hope you will find this information useful to move forward. If you are facing any difficulties with the implementation please do not hesitate to contact us. You may submit a dedicated ticket on the matter and we will be happy to assist.

Regards,
Nadezhda Tacheva
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/.