Run-time control

COOLjsTree and COOLjsTree Professional allow you to control trees via JavaScript. You can expand or collapse all nodes of the tree:

var tree = new COOLjsTree("tree1", TREE1_NODES, TREE1_FORMAT);

...

tree.expandAll();
tree.collapseAll();

Also, you can expand or collapse all subnodes of some specific node:

var tree = new COOLjsTree("tree1", TREE1_NODES, TREE1_FORMAT);

...
var node = tree.nodeByName('SubNode 1');
tree.expandAll(node);
tree.collapseAll(node);

You can toggle specific node, i.e. collapse it if it was expanded or expand it if it was collapsed:

var node = tree.nodeByName('Node 1');
// or
var node = tree.nodeByID(7);

if (node) tree.expandNode(node.index);

Nodes are counted from top to bottom. The very first node has index 0.