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 TreeNode
s is created, I'd like to put a custom attribute on it.
How do I get called back on the automatic creation of TreeNode
s 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);
}
});
精彩评论