Populate dojo ItemFileReadStore from Grails "render as JSON"
I have created a method in my controller that will give me a JSON "file" if I browse to that URL directly. It is only in memory, not on disk, as it is generated at the time you hit the URL. I am trying to use this as my data store for a dojo tree, however, when I am using this, the Tree never populates, it just sits there with the "waiting" cursor. Is there a different way to populate the data for the Tree?
Here is the code below. "getFilterTree" returns a开发者_StackOverflow社区 rendered JSON object in grails
var store = new dojo.data.ItemFileReadStore({
url: "/SkillsDB/search/getFilterTree"
});
var treeModel = new dijit.tree.ForestStoreModel({
store: store,
query: {
"type":"cat"
},
rootId: "root",
rootLabel: "Filter Categories",
childrenAttrs: ["children"]
});
new dijit.Tree({
model: treeModel
},
"treeOne");
It should definetely work.
For ItemFileReadStore, your json should comply with the structures shown in this page : http://dojotoolkit.org/reference-guide/dojo/data/ItemFileReadStore.html
精彩评论