Note that there are some explanatory texts on larger screens.

plurals
  1. PODojo JsonRest store and dijit.Tree
    primarykey
    data
    text
    <p>I'm having a some problem making JSonRest store and dijit.Tree with ForestModel. I've tried some combination of JsonRestStore and json data format following many tips on the web, with no success.</p> <p>At the end, taking example form here <a href="http://blog.respondify.se/2011/09/using-dijit-tree-with-the-new-dojo-object-store/" rel="nofollow">http://blog.respondify.se/2011/09/using-dijit-tree-with-the-new-dojo-object-store/</a></p> <p>I've made up this simple page (I'm using dojotolkit 1.7.2)</p> <pre><code>&lt;!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"&gt; &lt;html&gt; &lt;head&gt; &lt;meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"&gt; &lt;title&gt;Tree Model Explorer&lt;/title&gt; &lt;script type="text/javascript"&gt; djConfig = { parseOnLoad : true, isDebug : true, } &lt;/script&gt; &lt;script type="text/javascript" djConfig="parseOnLoad: true" src="lib/dojo/dojo.js"&gt;&lt;/script&gt; &lt;script type="text/javascript"&gt; dojo.require("dojo.parser"); dojo.require("dijit.Tree"); dojo.require("dojo.store.JsonRest"); dojo.require("dojo.data.ObjectStore"); dojo.require("dijit.tree.ForestStoreModel"); dojo.addOnLoad(function() { var objectStore = new dojo.store.JsonRest({ target : "test.json", labelAttribute : "name", idAttribute: "id" }); var dataStore = new dojo.data.ObjectStore({ objectStore : objectStore }); var treeModel = new dijit.tree.ForestStoreModel({ store : dataStore, deferItemLoadingUntilExpand : true, rootLabel : "Subjects", query : { "id" : "*" }, childrenAttrs : [ "children" ] }); var tree = new dijit.Tree({ model : treeModel }, 'treeNode'); tree.startup(); }); &lt;/script&gt; &lt;/head&gt; &lt;body&gt; &lt;div id="treeNode"&gt;&lt;/div&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>My rest service responds the following json</p> <pre><code>{ data: [ { "id": "PippoId", "name": "Pippo", "children": [] }, { "id": "PlutoId", "name": "Pluto", "children": [] }, { "id": "PaperinoId", "name": "Paperino", "children": [] } ]} </code></pre> <p>I've tried also with the following response (actually my final intention n is to use lazy loading for the tree)</p> <pre><code>{ data: [ { "id": "PippoId", "name": "Pippo", "$ref": "author0", "children": true }, { "id": "PlutoId", "name": "Pluto", "$ref": "author1", "children": true }, { "id": "PaperinoId", "name": "Paperino", "$ref": "author2", "children": true } ]} </code></pre> <p>Neither of the two works. I see no error message in firebug. I simply see the root "Subject" on the page. Thanks to anybody could help in some way.</p>
    singulars
    1. This table or related slice is empty.
    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.
 

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