ParadeTo / vue-tree-list

🌲A vue component for tree structure
http://paradeto.com/vue-tree-list/
MIT License
660 stars 127 forks source link

add expand method to TreeNode #71

Open rzorzorzo opened 4 years ago

rzorzorzo commented 4 years ago

currently one can only set expanded only for the complete tree and not for single nodes. it would be able to programmatically expand specific nodes.

TheFoot commented 4 years ago

I've created a PR that attaches a toggle() method to the node passed to the click event handler: https://github.com/ParadeTo/vue-tree-list/pull/93

TheFoot commented 4 years ago

Also (if it helps) I was able to expand/collapse the entire tree using:

toggleFileTree (expand = true) {

    // Only need to toggle top level nodes
    this
        .$refs[ 'treeView' ] // Needed to get access to Vue component
        .$children
        .forEach ( comp => {
            if ( expand === comp.expanded ) {
                comp.toggle ();
            }
        } )
    ;

}

toggleFileTree (true); // Expand all
toggleFileTree (false); // Collapse all