有没有一种很好的方法来扩展/关闭dijit.Tree中的所有可扩展节点?
对于那些寻找答案的人,请将其放入初始化代码中:
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); } });
至少,这对我有用.你可以用collapseAll()做同样的事情,你只需要切换_this._expandNode(node); with _this._collapseNode(node);
解决方法
是的,autoExpand = true(作为树的初始化参数).
如果你需要动态展开/折叠,Tree过去常常有一个方法,但我把它拿出来了.但是,您可以从以下位置复制它:http://bugs.dojotoolkit.org/changeset/20529.
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。