I have a vuetify treeview. It is selectable, meaning that each node comes with a checkbox. But there doesn't seem to be a way to get the node to expand when checked or collapse when unchecked. There is the open-on-click attribute, but that expands/collapses the node when you click on the node itself, not when you check/uncheck the checkbox. There is also the @input event which does fire when you check/uncheck the checkbox, but the event doesn't contain any information on which node was checked/unchecked (it only gives you an array of all the nodes that are checked).
The only workaround I can think of is to keep track of all the previously checked nodes and compare this with the currently checked nodes which the @input event gives you. If the currently checked nodes contain nodes that don't exist among the previously checked nodes, then expand those nodes (programmatically). If extra nodes exist in the previously checked nodes, collapse those nodes (programmatically). But this seems like such a complicated workaround, especially when you factor in the recursion you'll need to traverse the tree and expand/collapse all descendant nodes.
Is there a way to accomplish what I'm trying to do, or does the vuetify treeview not have this feature for checkboxes?
Aucun commentaire:
Enregistrer un commentaire