Qtree Defatult Expand All Doesn't work?
-
Hi. Here is my code. It’s very simple? Where is my wrong?
<q-tree :nodes="assemblies" label-key="name" node-key="id" default-expand-all :selected.sync="selectedAssembly" selected-color="primary"/>
I fetch the nodes from laravel kelnoy/nest… It doesn’t expand as default.
-
as you can see the ‘default’ q-tree auto expand is not broken:
https://quasar.dev/vue-components/tree#Example--Customizing-nodes
If you look at the api desciption of
default-expand-all
:Allow the tree to have all its branches expanded, when first rendered
So auto expand will only work when the q-tree is first rendered.
So it will not work if you’re fetching the nodes and change the nodes after the q-tree has first rendered. Instead you should call
expandAll()
on the q-tree ( using a ‘ref’) after you have populated the tree with your fetched data. -
@dobbel thank you… I added it into updated lifecycle hook and it’s ok…
updated () { this.$refs.asmTree.expandAll()