views:

448

answers:

1

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 before rendering?

+1  A: 

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);
    }
});
Bill Keese