Closed aprln closed 4 years ago
To answer my own question, you just need to set isExpanded
to true/false on the node data you want to expand/collapse
To expand on this solution ;) , I wrote a wrapper component around sl-vue-tree and exposed these methods:
expandNode(path) {
const node = this.$refs['tree'].getNode(path);
this._expandNode(node);
},
_expandNode(node) {
this.$refs['tree'].updateNode(node.path, { isExpanded: true });
if (node.level > 1) {
this.expandNode(node.path.slice(0, node.path.length -1 ));
}
},
Through out my usage of sl-vue-tree, I stick with paths to reference nodes, so this works for me and seems to be inline with the rest of the methods in sl-vue-tree. Hope it helps.
Hi, Is there a way to expand/collapse nodes programatically? Thank you!