Is there a good way to expand / close all expandable nodes in dijit.Tree ?
For those looking for an answer, put this in your initialization code:
var treeControl = new dijit.Tree({ model: treeModel, expandAll: function() { // summary: // Expand all nodes in the tree // returns: // Deferred that fires when all nodes have expanded var _this = this; function expand(node) { _this._expandNode(node); var childBranches = dojo.filter(node.getChildren() || [], function(node) { return node.isExpandable; }); var def = new dojo.Deferred(); defs = dojo.map(childBranches, expand); } return expand(this.rootNode); } });
At least it works for me. And you can do the same with collapseAll() , where you only need to switch _this._expandNode(node); on _this._collapseNode(node);
source share