You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Originally posted by pamtbaau July 15, 2024
I've two apps that use a TreeView. In both apps the TreeView needs to be dynamically updated by:
Adding/removing TreeViewItems
Replacing the value of a TreeViewItem (values are immutable objects)
Updating the content of the TreeViewItem depending on the replaced value.
I've tried two approaches:
Updating the underlaying tree of values (to-do's, or financial accounts/categories) and then rebuild the entire tree.
Issues
Requires storing and maintaining which TreeViewItem is selected and/or expanded outside the TreeView.
Requires recreating entire tree after each insert/delete/update of underlaying values and apply selected/expanded properties.
Adding/removing TreeviewItems to/from the children property of the parent.
Issues
The content and value of a TreeViewItem are final and cannot be updated. This requires creating a new TreeViewItem and replacing the outdated one.
Both approaches feel awkward...
Questions:
Is there something I've overlooked and can help in updating a tree dynamically?
Any other approach I could try?
Current Solution
The current only way to dynamically update a TreeView is by making it lazy and providing the items outside of it. When the items are loaded, just update the variable that holds that data and setState.
Expected Solution
To give more finer control to the tree view, a TreeViewController should be created. It would hold information about the attached TreeView. Additionally, it would give much more breath to the tree view widget itself, moving the logic to a contained place.
With the controller, one could:
Look for items (controller.getItemFromValue('item_value'));
Discussed in #1085
Originally posted by pamtbaau July 15, 2024
I've two apps that use a TreeView. In both apps the TreeView needs to be dynamically updated by:
I've tried two approaches:
Issues
selected
and/orexpanded
outside the TreeView.children
property of the parent.Issues
content
andvalue
of a TreeViewItem are final and cannot be updated. This requires creating a new TreeViewItem and replacing the outdated one.Both approaches feel awkward...
Questions:
Current Solution
The current only way to dynamically update a TreeView is by making it lazy and providing the items outside of it. When the items are loaded, just update the variable that holds that data and
setState
.Expected Solution
To give more finer control to the tree view, a
TreeViewController
should be created. It would hold information about the attachedTreeView
. Additionally, it would give much more breath to the tree view widget itself, moving the logic to a contained place.With the controller, one could:
controller.getItemFromValue('item_value')
);controller.appendItem( ... )
);controller.removeItem( ... )
);Additional Context
The text was updated successfully, but these errors were encountered: