PDA

View Full Version : static treePanel question



wki01
30 Jun 2010, 2:22 AM
The tree is initially appears correctly with rootNodeONE.
When I press the button I see rootNodeTWO.
This does not work.
How can I do?
Thanks



........
var rootNodeONE = {
"text":"ROOT NODE ONE",
"expanded":"false",
"children": [
{"text":"ONE",
"cls":"folder",
"children": [
{"text":"ONE",
"leaf":"true"}
]}
]}

var rootNodeTWO = {
"text":"ROOT NODE TWO",
"expanded":"false",
"children": [
{"text":"TWO",
"cls":"folder",
"children": [
{"text":"TWO",
"leaf":"true"}
]}
]}

var treePanel = {
xtype : 'treepanel',
id : 'treePanel',
title: 'Tree',
autoScroll : true,
root: rootNodeONE,
buttons: [{
text: 'TWO',
handler:function(){
Ext.getCmp("treePanel").root = rootNodeTWO
Ext.getCmp("treePanel").getRootNode().reload();
}
}]
}
........

Animal
30 Jun 2010, 3:18 AM
You cant' just set the "root" property.

http://www.sencha.com/deploy/dev/docs/?class=Ext.tree.TreePanel&member=setRootNode

And reload()? It hasn't been loaded.

You want it to expand?