PDA

View Full Version : [SOLVED] How to get a id of selected node in Async Tree



Gauser
21 May 2009, 11:20 AM
Hi

I have a simple tree and a big problem.



new Ext.tree.TreePanel({
loader:new Ext.tree.TreeLoader(),
id:'tree2',
width:200,
autoScroll:true,
root:new Ext.tree.AsyncTreeNode({
expanded:true,
checked:true,
autoScroll:true,
leaf:false,
text:'Root',
children:[{
text:'ss',
id:'1',
leaf:true
},{
text:'ss2',
id:'2',
leaf:true
}]
})
})
I need to add a callback, wich show me an id value of selected node(child)
I had a few mixes of getSelectionModel.getSelected but they did not work.
Please help.

Animal
21 May 2009, 11:29 AM
"tried mixes"?

Why not just read the manual and do it?

http://extjs.com/deploy/ext-3.0-rc1.1/docs/?class=Ext.tree.DefaultSelectionModel&member=getSelected

What does it return?

And what do you see when you then look at the API docs for that?

http://extjs.com/deploy/ext-3.0-rc1.1/docs/?class=Ext.tree.TreeNode

Gauser
21 May 2009, 11:55 AM
"tried mixes"?


What do you mean ?




Why not just read the manual and do it?

And what do you see when you then look at the API docs for that?


Believe me Animal, forum is the last place, where I lookin for answers.

I have a solution already:



new Ext.tree.TreePanel({
loader:new Ext.tree.TreeLoader(),
anchor: '90%',
autoScroll:true,
id:'tree2',
name:'category',
bodyStyle:'background:white;',
root:new Ext.tree.AsyncTreeNode({
expanded:true,
leaf:false,
text:'Root',
animCollapse:true,
animate:true,
id:'0',
children:[{
text:'First',
leaf:false,
id:'1',
children:[{
text:'Sub 1.1',
id:'100'
}]
},{
text:'Second',
leaf:true,
id:'2'
}]

}),listeners: {
click: {
fn: function(node, event){
alert(node.id);
},
}
}
})

sanchez
3 Jun 2009, 6:51 AM
Hi Gauser, this is working form me, tray it.

MyTreePanel.on("click", function(node){
alert(node.id);
node.setText("This the new text for this node");
});


I think, is better but what about support teem (ANIMAL) ?

I hope this may help you, see you!!!