vuetify icon indicating copy to clipboard operation
vuetify copied to clipboard

[Feature Request] Allow Treeview nodes to be selected independently of children

Open naffarn opened this issue 7 years ago • 10 comments

Problem to solve

Sometimes it is desirable to have a parent node selected when there are only some or none of the child nodes selected.

In my case, I am applying categories to an object, and the children are subcategories.

Using music genres as an example:

  • [x] Dance Music
    • [x] Chillstep
    • [ ] Deep House
    • [ ] Dubstep
    • [ ] Electroswing
    • [x] Hardcore
      • [ ] Breakcore
      • [ ] Hardstyle
  • [ ] Country Music
    • [ ] Folk

I want to mark something as Hardcore, but not a subgenre. In the bound model for the treeview, I want to see Dance music and Hardcore selected.

In the case of an album, I'd also like to be able to specify that there are chillstep songs on there too, being able to select multiple child nodes.

The functionality that I'd like is basically the reverse of the current functionality - Selecting a node marks its parents a selected, and ignores the children.

Proposed solution

Have a prop on the treeview called reverse, inverse, select-parents or something to that effect. Setting this to true changes the selection methodology - select the node and its parents, rather than a node and its children.

naffarn avatar Jul 11 '19 07:07 naffarn

+1 would love to see this feature too. Looks similar to this issue: https://github.com/vuetifyjs/vuetify/issues/6759

fsproru avatar Aug 19 '19 05:08 fsproru

Hey, looks like this has been requested from three users (me included). Any chance to see this feature in the next releases?

trane77 avatar Jul 27 '20 13:07 trane77

Same problem here. It would be nice to retrieve just a parent object or attach a @click event to a full parent node.

reymad avatar Sep 18 '20 10:09 reymad

Apparently there's not much interest around this feature...if I happen to have some free time, I can try to implement it and open a PR, there's someone else interested? It doesn't look like a complex task, anyway if there's anybody that wants to help, it would make things faster.

trane77 avatar Sep 19 '20 15:09 trane77

Hi @funder7 ! Just wondering ... did you find some free time to implement this feature?

cur53se avatar Feb 14 '21 23:02 cur53se

Hi @danielchodusov , unfortunately I was really busy in the last months, so I wasn't able to implement it.. BTW I've appended two buttons on the side of each father element, to select or deselect all it's children in a single operation. It's a momentary workaround, but it does the job.

If you're interested, I can share the code. Cheers

trane77 avatar Feb 14 '21 23:02 trane77

I'm in the same boat. I'm writing a File-Browser example/tutorial with Electron and I need the get the activated/clicked (parent) node, so I can list the files an the right side of this folder. Maybe an additional option how the selection event (input) would also be fire if the user selects/clicks on a parent node.

@funder7 I would love to see the work-around.

bromix avatar Feb 26 '21 09:02 bromix

Hi @bromix, here's the workaround, it's a simple solution, not the best, but does the job for the moment :)

Check out the gist

Note: I had to remove some code, it should work as expected though. There is also some example data (items), I wrote this code some time ago, probably that is default structure expected by treeview to show nested items. Some comments & logging remained in place, maybe it can help you to understand how it works!

Happy coding :)

trane77 avatar Mar 03 '21 17:03 trane77

thanks @funder7. This will me help to work around it. Have a nice weekend :)

bromix avatar Mar 06 '21 14:03 bromix

Duplicate of #7799

If you have any questions, please reach out to us in our Discord community.

johnleider avatar Jul 28 '21 23:07 johnleider