Declined
Last Updated: 19 Jul 2023 14:24 by Nicholas
Nicholas
Created on: 13 Jul 2023 20:02
Category: UI for Blazor
Type: Feature Request
0
TreeView Allow binding to .Selected and .Checked

In TreeView the selected and checked items have to be provided as IEnumerable<object>.  This can make things a bit of a pain if you have for example outside events that are also trying to change the list of checked items. Not insurmountable or hard but just a pain.

For example to remove an item since IEnumerable is immutable you to have to completely re-assign the collection.  SelectedItems = SelectedItems.Where[Some condition] .  Instead of SelectedItems.Remove, add etc.

I realize the reasons you are binding to IEnumerable<object> and not using generics 

I propose adding "CheckedField" and "SelectedField" in your observable treeview binding and then we would not have to pass in Checked / Selected Items at all and just bind those fields to the Data we are passing in.  Make life a lot easier.

The same thing likely applies to some other controls that have the same problem.  So keep it consistent.

4 comments
Nicholas
Posted on: 19 Jul 2023 14:24
Yeah it's a pain.  I guess I'm just complaining at this point and I'll be quiet now.
ADMIN
Dimo
Posted on: 19 Jul 2023 14:22

Yes, the SelectedItems parameter is IEnumerable<object> because the TreeView supports different item types at different levels.

By the way, you would need to reassign the SelectedItems collection even if it was a List, otherwise Blazor wouldn't detect the change and update the UI.

Regards,
Dimo
Progress Telerik

Stay tuned by visiting our public roadmap and feedback portal pages! Or perhaps, if you are new to our Telerik family, check out our getting started resources!
Nicholas
Posted on: 19 Jul 2023 13:44
The other examples bind to IEnumerable<T>  TreeView binds to IEnumerable<object> which is where the bulk of the paint comes from.
ADMIN
Dimo
Posted on: 19 Jul 2023 08:37

Hi Nicholas,

Actually, we are going the opposite way for all our components and parameters. For example, the TreeView's expanded items used to depend on a data item property, but we removed that in favor of an ExpandedItems collection as a component parameter.

In a similar fashion, the Grid SelectedItems is a component parameter, rather than a data item property.

Based on customer feedback and internal evaluation of the component architecture, we believe the current state of affairs is the better one.

Regards,
Dimo
Progress Telerik

Stay tuned by visiting our public roadmap and feedback portal pages! Or perhaps, if you are new to our Telerik family, check out our getting started resources!