Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature Request] Create TreeViewController #1140

Open
bdlukaa opened this issue Nov 19, 2024 Discussed in #1085 · 0 comments
Open

[Feature Request] Create TreeViewController #1140

bdlukaa opened this issue Nov 19, 2024 Discussed in #1085 · 0 comments
Labels
enhancement New feature or request w: TreeView Related to the TreeView widget

Comments

@bdlukaa
Copy link
Owner

bdlukaa commented Nov 19, 2024

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:

  • 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'));
  • Add items (controller.appendItem( ... ));
  • Remove items (controller.removeItem( ... ));

Additional Context

@bdlukaa bdlukaa added the enhancement New feature or request label Nov 19, 2024
@bdlukaa bdlukaa added the w: TreeView Related to the TreeView widget label Jan 31, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request w: TreeView Related to the TreeView widget
Projects
None yet
Development

No branches or pull requests

1 participant