Opened 14 years ago
Closed 14 years ago
#2868 closed defect (wontfix)
TreeV3 compatible TreeControllerExtension
Reported by: | guest | Owned by: | bill |
---|---|---|---|
Priority: | high | Milestone: | |
Component: | Widgets | Version: | 0.4.2 |
Keywords: | Cc: | ||
Blocked By: | Blocking: |
Description
Currently (in the nightly build as of 4/25/07) TreeControllerExtension? doesn't work with TreeV3 trees. This modified widget does (and it's simpler now, to boot):
dojo.provide("dojo.widget.TreeControllerExtensionV3"); dojo.declare( "dojo.widget.TreeControllerExtensionV3", null, { // kept this from dojo.widget.TreeControllerExtension, as it does what we need saveExpandedIndices: function(node, field) { var obj = {}; for(var i=0; i<node.children.length; i++) { if (node.children[i].isExpanded) { var key = dojo.lang.isUndefined(field) ? i : node.children[i][field]; obj[key] = this.saveExpandedIndices(node.children[i], field); } } return obj; }, restoreExpandedIndices: function(node, savedIndices, field) { for(var i=0; i<node.children.length; i++) { var child = node.children[i]; var found = false; var key = -1; // process field not set case if (dojo.lang.isUndefined(field) && savedIndices[i]) { found = true; key = i; } // process case when field is set if (field) { for(var k in savedIndices) { //dojo.debug("Compare "+k+" "+child[field]) if (k == child[field]) { found = true; key = k; break; } } } // if we found anything - expand it if (found) { this.expand(child); // recursively expand as needed this.restoreExpandedIndices(child, savedIndices[key], field); } else if (child.isExpanded) { // not found, so collapse dojo.lang.forEach(child.getDescendants(), function(elem) { this.collapse(elem); }); } } } });
Note: See
TracTickets for help on using
tickets.
TreeControllerExtension? not part of Tree in Dijit; it's all been reworked.