PDA

View Full Version : selecting a leaf in a tree



LJH
23 Mar 2010, 5:56 AM
I am pretty new to the EXTJS. Does anyone can help how to select a leaf in a tree? Below is what I am trying to do.

My 'tree-data.json' has the following entries for now.

[{
text:'Indicators',
expanded: true,
children:[{
text:'Annual Inflation',
id:'inf',
leaf:true
},{
text:'GDP',
id:'gdp',
leaf:true
}]
},{
text:'Countries',
children:[{
text:'United States',
id:'us',
leaf:true
},{
text:'China',
id:'chn',
leaf:true
}]
}]

I can select any leaf under the 'Indicators' folder. For example, I can select the 'GDP' using this code.

loader: new Ext.tree.TreeLoader({
dataUrl:'tree-data.json'
}),

root: new Ext.tree.AsyncTreeNode()
});

treePanel.root.expand(true, true, function(n) {n.firstChild.childNodes[1].select();});


My question is how to select a leaf in the second folder, such as the 'United States' or 'China.'

Thanks in advance.