Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>In fact, it is possible. Analyzing the code of Dojo's <code>Tree.js</code>, led me to the conclusion, that the function that is called on every node expand is </p> <pre><code>_expandNode: function(/*TreeNode*/ node) </code></pre> <p>The function contains the following code:</p> <pre><code>// Load data if it's not already loaded if(!node._loadDeferred){ // load the node } </code></pre> <p>Our culprit is the <code>_loadDeferred</code> property, of course. So the question was, how to set this property for each expanded node.</p> <p>I decieded to do that in <code>getChildren</code> method. First I needed to get the tree node based on item from the store and then I had to set its property to false.</p> <ol> <li><p>I found out that <code>tree.getNodesByItem(item)</code> does to first part. The only thing to remember is it returns an array of nodes, so we need to take the first element:</p> <pre><code>tree.getNodesByItem(item)[0] </code></pre></li> <li><p>Now it's only a matter of setting the property:</p> <pre><code>tree.getNodesByItem(item)[0]._loadDeferred = false; </code></pre></li> </ol> <p>So, the <strong>final solution</strong> is</p> <pre><code>var store = new Observable(new JsonRest({ target: "...", idProperty: "id", mayHaveChildren: function(object) { return object.hasChildren; }, getChildren: function(object, onComplete, onError) { this.get(object.id).then(function(fullObject) { object.children = fullObject.children; onComplete(fullObject.children); tree.getNodesByItem(object)[0]._loadDeferred = false; }, onError); }, getRoot: function(onItem, onError) { this.get("I1").then(onItem, onError); }, getLabel: function(object) { return object.name; } })); </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. VO
      singulars
      1. This table or related slice is empty.
    2. 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