开发者

Adding attributes to a dojo tree node on creation

I'm using a dojox.data.QueryReadStore to populate a dijit.Tree dynamically on expansion of each node. When each of the child TreeNodes is created, I'd like to put a custom attribute on it.

How do I get called back on the automatic creation of TreeNodes be开发者_运维百科fore rendering?


Currently it calls _createTreeNode() to create each TreeNode, so you can just connect to that

<div dojoType=dijit.Tree ...>
    <script type="dojo/connect" event="_createTreeNode"> ... </script>
...

If you want to do something fancier, you could customize the TreeNode class:

dojo.declare("MyTreeNode", dijit._TreeNode, { ... })

and then make a custom Tree class that uses it:

dojo.declare("MyTree", dijit._Tree, {
    _createTreeNode: function(/*Object*/ args){
          return new MyTreeNode(args);
    }
});
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜