View Full Version : Extend Ext.ux.tree.TreeGrid and use data

21 Dec 2010, 4:08 AM
Hallo, I want to use a custom and reusable component based on Ext.ux.tree.TreeGrid.

I've add a default grid structure and a toolbar.

For the business logic (enable or not buttons in the toolbar) in my component I've to evaluate some data loaded in the base component.

Ext.ux.tree.TreeGrid uses a Ext.ux.tree.TreeGridLoader and Ext.ux.tree.TreeGridNodeUI that extends Ext.tree.TreeNodeUI.

How to get some value in the Ext.ux.tree.TreeGrid after is rendered?

I've logged the component in firebug but without success.

21 Dec 2010, 4:18 AM
Each tree node has 'attributes' collection which has all the properties you set for the corresponding node via JSON response.

21 Dec 2010, 5:23 AM
If I log "this" my element I see that there is a root property and a sub called childNodes that is an array at the index 0 I see every root params with correct values (what I'm looking for)

but if I log this.root.childNodes[0].myatribute firebug tells me that is undefined


@MaximGB: I'm looking for the value of an attribute in the root node, but firebug tells me that root.attributes has only id->value and text->value ..... not what I'm looking for

any suggestion?

21 Dec 2010, 5:31 AM
No, it's:

(and only after the root node has loaded)

21 Dec 2010, 5:51 AM
Probably my error is that the root node is not yet loaded.

this.getRootNode().childNodes[0].attributes.myattribute, returns "undefined"

In the same position if i log only "this" I can see every collected attributes.

I want to performa a control to enable or not buttons in my toolbar, in my initComponent function:

initComponent: function() {


///////// PERMESSI //////////

var myControl = this.getRootNode().childNodes[0].attributes.remoteControl

if (!Ext.isIE) console.log(myControl); // UNDEFINED
//console.log(this); // It's ok log my component with nodes and atributes and remoteControl too
//console.log(this.root.childNodes[0].remoteControl); // UNDEFINED too

// if (myControl) do something

21 Dec 2010, 6:07 AM
Every time I log only "this" (my component) i can see:


id_assegnazioni is my control variable.

21 Dec 2010, 6:20 AM
The root won't be loaded in initComponent (unless you explicitly force it to load by calling the loader).

21 Dec 2010, 6:31 AM
A little example?

I've tried to setup a listener in initComponent with this.on('afterrender', this.MyFunCtionToControl, this);

and in MyFunCtionToControl i look for my control value. But the problem is the same!

Probably is correct to link a function to the "load" event of the Ext.ux.tree.TreeGridLoader but how to?

21 Dec 2010, 6:39 AM
Eureka! the solution is (i don't know if the best solution):

I've added a event listener to the initComponent function so:

this.loader.on('load', this.performControl, this);

In performControl I can do wath I want....