Need More Info
Last Updated: 23 Sep 2020 15:32 by Darren
Marin Bratanov
Created on: 06 Jan 2020 14:18
Category: TreeView
Type: Feature Request
1
Expanded Items Handling - Feedback Requested

Hi everyone,

We created this item to request your feedback on how you use the treeview binding with regards to the Expanded state of the nodes.

At the moment, the treeview updates the field in the collection when an item gets expanded or collapsed, and that makes it unique in the suite - the other data bound components do not alter their data source silently, and this is the general pattern we want to follow in order to have consistency across the board.

Thus, there are several approaches we are considering and we want to get your take on how you would find this most comfortable:

  • Keep the current situation where the treeview updates the ExpandedField in the Data silently [we would rather change it] - the Data collection gets changed automatically. To control an expanded item, prepare the data source accordingly.
  • Use the OnExpand event to get the item and its new state in order to update the collection yourself if needed. If you don't use the field for anything but to control the state of the treeview, you will not need to change anything. To control an expanded item, prepare the data source accordingly when providing it to the treeview. If you will be reusing the same data source with alterations, you may have to handle the event to sync the state between the treeview and the data.
  • Use an ExpandedItems collection [we are inclined to go with this approach at the moment] - this will be a collection that you can provide to the treeview separately from its data source, like the selected items in a grid. This will let you avoid an Expanded field in the data (which we believe may not be present in an actual database anyway) and you will be able to use business logic to determine which items to add/remove to that collection, this also includes nested levels, even added through load-on-demand.
6 comments
Darren
Posted on: 23 Sep 2020 15:32
I'd prefer the ExpandedItems collection.   I think it would make sense given SelectedItems is used to track the selected state. 
Daniel
Posted on: 04 Sep 2020 20:44

Hi there,

i am voting for the OnExpand event approach. I consider this the traditional approach as this is used by other frameworks too and ... it just works. UI and Backend should be separated hence selecting data specifically as a view model for the tree view is pretty straightforward and it should be the way to go. The view model would contain a Expanded property because it's a view model and a view model describes the view hence the expanded state is part of the view.

So lonG

Daniel

ADMIN
Marin Bratanov
Posted on: 28 Jun 2020 11:56

Thank you for your feedback, RĂ©mi, I will make sure the dev team gets it.

 

Regards,
Marin Bratanov
Progress Telerik

Progress is here for your business, like always. Read more about the measures we are taking to ensure business continuity and help fight the COVID-19 pandemic.
Our thoughts here at Progress are with those affected by the outbreak.
Rémi
Posted on: 26 Jun 2020 08:27

Hi,

I also like the ExpandedItems collection.

Another approch I would prefer is a "visibility" collection with ids

With the Expanded* solution this mean I must expand the father to display the son. With visibility list I only have to deal with final nodes, not the parent.

<TelerikTreeView @bind-VisibleItemsIds="VisibleItemIdsList">

and have the id definition IdField = "@(nameof(TreeItem.Id))" somewhere (TelerikTreeView or TreeViewBinding)

=> This kind of list is easy to serialize in database to save treeview state. It also naturaly handle treeview modification (if we add or remove items).

Remi

ADMIN
Marin Bratanov
Posted on: 11 May 2020 13:00

To made sure I understand you correctly, Lee - you would prefer the ExpandedItems collection approach, like in the grid row selection?

 

Regards,
Marin Bratanov
Progress Telerik

Progress is here for your business, like always. Read more about the measures we are taking to ensure business continuity and help fight the COVID-19 pandemic.
Our thoughts here at Progress are with those affected by the outbreak.
Lee
Posted on: 10 May 2020 13:04
I agree with your approach as it is not always convenient for us to include a IsExpanded field in our model, and certainly doesn't make sense from a UI / business logic POV (i.e user 1 might have some items expanded, user 2 might not, so we shouldn't be persisting this information in the DB)