jqTree icon indicating copy to clipboard operation
jqTree copied to clipboard

Expand all branches of a selected node.

Open husseinkhatib opened this issue 11 years ago • 4 comments

Hi Mbraak,

Is there any function to open all BRANCHES OF THE SELECTED NODE?

husseinkhatib avatar Apr 17 '15 07:04 husseinkhatib

You could do something like this:

// open children of node 'Saurischia'
var node = $tree.tree('getNodeByName', 'Saurischia');

node.children.forEach(function(child) {
    if (child.isFolder()) {
        $tree.tree('openNode', child);
    }
});

Note that this example uses the Array.forEach function, which is not available in ie8.

mbraak avatar Apr 17 '15 09:04 mbraak

Sorry mbraak , I executed you suggestion code the result as following: not all branches of selected node will opened. they opened only the parents below the selected node.

husseinkhatib avatar Apr 17 '15 09:04 husseinkhatib

You could do the following:

var node = $tree.tree('getNodeByName', 'Saurischia');

node.iterate(function(child) {
    if (child.isFolder()) {
        $tree.tree('openNode', child);
    }

    return true;
});

mbraak avatar Apr 17 '15 10:04 mbraak

Thank you for help :)

husseinkhatib avatar Apr 17 '15 10:04 husseinkhatib