N00ts / vue3-treeview

a simple treeview in vue js 3
MIT License
73 stars 65 forks source link

Programatically set focused node #36

Closed muzicaed closed 1 year ago

muzicaed commented 1 year ago

Hi!

Thanks for a really nice library! I have a use case that I think is not covered with the current implementation.

I use this component to display a folder structure in my project. The idea is that the user should use the tree to select a parent for an item. This works perfectly when creating a new item by using the node-focus event to see what node was selected.

But, when the user wants to edit an item in my application, I see no way to programatically select a node in the tree. Ie. I have the selected id from database and I want to display the tree with that particular node pre-selected in the tree.

Im not sure if there currently is a way to do this that Im not seeing or if this might be a missing feature?

muzicaed commented 1 year ago

I found a way using the check boxes. When checking a box I just programatically unchecked last checked and thereby forcing a "singel selection". This was actually better, as the focus was removed when eg. clicking on another field etc.