Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Here's a problem with Layke's solution (which otherwise does work) found by pre-production testing for a commercial website.</p> <p>Case 1:</p> <ul> <li>Create &amp; populate a tree.</li> <li>Click on a node to select.</li> <li>Execute refreshTree as in Layke's solution.</li> <li>Click on a node, get error "this.labelNode is undefined".</li> </ul> <p>Now start again, case 2:</p> <ul> <li>Create &amp; populate a tree.</li> <li>Click on a node to select.</li> <li>Ctrl-click on the previously selected node. </li> <li>Execute refreshTree as in Layke's solution.</li> <li>Click on a node, no error.</li> </ul> <p>The stored selection references to the first selection are being used to undo the selection attributes (background color, etc.) when the second selection is made. Unfortunately, the referred-to objects are now in the bit-bucket. The modified code appears to be production-ready, i.e. hasn't failed any pre-production tests.</p> <p>The solution is to put:</p> <pre><code>Tree.dndController.selectNone(); </code></pre> <p>prior to first line of Layke's refreshTree solution above.</p> <p>In response to meta suggestions, here it is:</p> <pre><code>refreshTree : function() { // Destruct the references to any selected nodes so that // the refreshed tree will not attempt to unselect destructed nodes // when a new selection is made. // These references are contained in Tree.selectedItem, // Tree.selectedItems, Tree.selectedNode, and Tree.selectedNodes. Tree.dndController.selectNone(); Tree.model.store.clearOnClose = true; Tree.model.store.close(); // Completely delete every node from the dijit.Tree Tree._itemNodesMap = {}; Tree.rootNode.state = "UNCHECKED"; Tree.model.root.children = null; // Destroy the widget Tree.rootNode.destroyRecursive(); // Recreate the model, (with the model again) Tree.model.constructor(dijit.byId("myTree").model) // Rebuild the tree Tree.postMixInProperties(); Tree._load(); } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload