Note that there are some explanatory texts on larger screens.

plurals
  1. POUsing Dijit.Tree with QueryReadStore for Lazy Loading
    text
    copied!<p>I'm trying to use dojox.data.QueryReadStore as the store for a lazy loading dijit.tree. I seem hard pressed to find examples of people using this store instead of JsonRestStore, but I would really like to stick to using query strings as opposed to REST syntax for the sake of consistency throughout my application. The trouble is, while I can get QueryReadStore to pass along the root level of the tree, lazy loading the children, it always fails. </p> <p>Here's what I have:</p> <pre><code> dojo.require("dojox.data.QueryReadStore"); dojo.require("dijit.Tree"); dojo.addOnLoad(function() { var store = new dojox.data.QueryReadStore({ url:'/cgi-bin/safari/safari_json_responder.pl', requestMethod: "get" }); var treeModel = new dijit.tree.ForestStoreModel({ store: store, deferItemLoadingUntilExpand: true, query: { 'id' : "0" }, childrenAttrs: ["children"] }); var myTree = new dijit.Tree({ model: treeModel }, "treeOne"); myTree.startup(); }); </code></pre> <p>When I click to expand one of the categories that has children, I get this error from Firebug:</p> <blockquote> <p>Node cannot be inserted at the specified point in the hierarchy" code: "3 [Break On This Error] (function(){var _1=null;if((_1||(typeo...setTimeout(dojo._loadInit,100);}})(); </p> </blockquote> <p>Any suggestions on what might be the issue? You can see the live test page here:</p> <p><a href="http://asisaid.com/safari-resources/lazyLoad.html" rel="nofollow">http://asisaid.com/safari-resources/lazyLoad.html</a></p> <p><strong>Updated observations 19-Jun-2011:</strong></p> <p>I noticed isItemLoaded appears to claim to be incomplete in QueryReadStore. Perhaps the Dojo documentation saying QueryReadStore can handle lazy loading is incorrect? I've been trying to replace the QueryReadStore.isItemLoaded method, but haven't been able to figure out what it <em>should</em> do. I tried looking for the attribute "$ref" or "_reference," but that doesn't seem to be working. </p> <p>Clearly, I am doing something wrong. Although somehow I feel like I'm on the right track. If I could notify the model that an item isn't entirely loaded, perhaps things would spring into action as they should (and do with JsonRestStore).</p> <p>Here's what the data being output looks like right now when id=0 is passed to the server:</p> <pre><code>{"label":"name","identification":"id","items":[{"name":"Autobiographical","poid":"0","id":"3"},{"name":"Blogging","poid":"0","children":[{"name":"asisaid","id":"2","$ref":"2"},{"name":"blogware","id":"4","$ref":"4"}],"id":"1","$ref":"1"}, [...] </code></pre> <p>(truncated off to keep it from being too long.)</p> <p>I've thrown references and data here and there trying different things (I'm sure I have too many in this example, but I've been trying to throw everything and see what sticks). </p> <p>It originally looked like this for id=0:</p> <pre><code>{"label":"name","identification":"id","items":[{"name":"Autobiographical","poid":"0","id":"3"},{"name":"Blogging","poid":"0","children": "true","id":"1","$ref":"1"}, [...] </code></pre> <p>I also tried this:</p> <pre><code>{"label":"name","identification":"id","items":[{"name":"Autobiographical","poid":"0","id":"3"},{"name":"Blogging","poid":"0","children": [{"$ref":"2" },{"$ref":"4"}],"id":"1"}, [...] </code></pre> <p>None of these ideas (nor the same thing, but using "_reference" instead of "$ref" seems to do the trick.</p>
 

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