开发者

dojo tree maintenance problem

I am creating a dojo tree on Mozilla 3 programatically as following

var store = new dojo.data.ItemFileReadStore({
 "id": "treeSt",
 "data": _treeData
    }
);
var model = new dijit.tree.ForestStoreModel({
 "jsId": "tModel",
 "store": store,
 "rootId": "tems",
 "rootLabel": "TEMS",
 "query": {

"type": "r开发者_StackOverflowoot" }, "childrenAttr": ["children"] });

var tree = new dijit.Tree({
 "id": treeId,
 "model": model,
 "openOnClick": false,
 "onClick": setSelectedNode
    }
);

Everytime a node is to be added to the tree, I update my global variable _treeData, destory and recreate the tree. _treeData has all the json data for the tree. Is there any other way to maintain tree-data without having to maintain a global variable?

Moreover, when I try to serialize _treeData using dojo.toJson(_treeData) , I get an error - "Too Much Recursion" in firebug console. Is there any other way to do this?

Thanks, in advance, for your help.


You can set 'url' attribute on dojo.data.ItemFileReadStore and load data from server.

To refresh the store we have to call the fetch() function.

If you could you ItemFileWriteStore you can use the newItem() function to just add only the new item instead of changing the entire store.

More information rgarding store is available at http://www.dojotoolkit.org/reference-guide/quickstart/data/usingdatastores/faq.html

Hope it helps.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜