PDA

View Full Version : Get TreeNode anchor



yo_haha
24 Oct 2012, 7:49 AM
Hi,

I have a TreePanel with a root child and grand-child:


tree = new Ext.tree.TreePanel({
useArrows: true,
animate: true,
title: "Couches",
enableDD: true,
root: {
nodeType: "async",
expanded : true,
children: [{
text: 'Fond de plan',
checked: true,
draggable: false,
leaf: false,
expanded: true,
singleClickExpand: true,
children: [{
text: 'Open Street Map',
draggable: true,
checked: true,
leaf: true,
listeners:{
'checkchange': function(node, checked){
osm.setVisibility(checked);
}
}
}]
,listeners:{
'checkchange': function(node, checked){
node.eachChild(function(n) {
n.getUI().toggleCheck(checked);
});
}
}
}
]
},
border: true,
region: "south",
height: 300,
split: true,
autoScroll: true,
containerScroll: true,
rootVisible: false,
lines: false
});
tree.getRootNode().expand();
tree.getRootNode().expandChildNodes();


When I call the method:


tree.getRootNode().firstChild.firstChild.text;

I get the expexted answer : Open Street Maps.
And when I call:


tree.getRootNode().firstChild.firstChild.getUI();

I get the UI object as an answer.
but when I call:


tree.getRootNode().firstChild.firstChild.getUI().getEl();

or


tree.getRootNode().firstChild.firstChild.getUI().getAnchor();

I get undefined as an answer.
When I try:


tree.getRootNode().firstChild.firstChild.getUI().hide();

The treeNode hides from the UI as expected.

Is there a way to get the anchor element of the treeNode?

Regards.

mitchellsimoens
27 Oct 2012, 12:45 AM
Just tried it on an example and it worked for me.

yo_haha
27 Oct 2012, 12:43 PM
Did you try the same example I provided?
Could you please post your example so I can compare?

Thanks.

mitchellsimoens
27 Oct 2012, 1:26 PM
I tried with the check tree example that comes with Ext JS 3

yo_haha
6 Dec 2012, 9:35 AM
I'm a bit lost...
I copied my tree into an empty html file and rendered the tree to a div. I get no problem with tree.getRootNode().firstChild.firstChild.getUI().getAnchor()
It returns the object I want.
But inside the original file with the rest of the application code, tree.getRootNode().firstChild.firstChild.getUI().getAnchor() returns "undefined".
Is this normal ?