Q-Tree: How to retrieve the filtered nodes instead of the entire nodes
-
Hi, I am currently using the tree component for my quasar web app.
When I select a node from the tree I want to retrieve my nodes filteredFor example, when I select the node “Good food”, I want to retrieve “Good food” with only one child (because I filtered). But instead I got it with 2 children.
Here the example without filter
Here is my codepen : https://codepen.io/FGremy/pen/yLVMdVj?editors=1010
Do you know a way to only retrieve the filtered nodes ?
Thanks for your attention
-
@beets @metalsadman any ideas? I can only come up with something complicated
-
@florentin you will have to filter the nodes again in the selected.
-
Hi @metalsadman, if I do that in the example, I wont keep the node “satisfied customers”.
Or there is something i dont get ?
-
@florentin try to console.log your qtree’s
meta
property, see what’s in there. ie.console.log(this.$refs.qTreeRef.meta)
. -
@Florentin I had been wondering this too, and although it feels hacky, it works. I used the Vue devtools to inspect the tree instance and you can see that the filtered nodes are in the tree’s refs.
I’ve built on your codepen example to spit out the node names, you should be able to adjust to your needs from there (I attached it to the input function of q-input, so try clearing then typing in and you’ll see the selected nodes at the top.
-
very nice!
-
@xdesai Thanks a lot, it’s perfectly what i was searching for