phphe/he-tree-vue

Expand all ancestors

JohnnyMaynne opened this issue · 5 comments

Hello. Is it possible to expand all ancestors for a particular node. I want to create a list of pages and when visiting subpages expand their ancestors.

phphe commented

here is example. change path to yours.

const path = [5,1,1]
tree.foldAll() // fold all nodes
path.forEach((v, i) => {
  tree.unfold(tree.getNodeByPath(path.slice(0, i+1)))
});

Thanks for the reply, but I am getting an error:

image

Here is the code that I will use:

image

phphe commented

foldAll should be this.$refs.tree.foldAll(). And try short path first. Make sure the path is right.

For foldAll I used import {foldAll} from 'he-tree-vue'

I wrapped the code in setTimeout and he earned, but for some reason it seems to me that this is not a very clean approach:

image

Either way, it works. Thanks for the help👍