PDA

View Full Version : TreePanel, reload and save state



alessandro
23 Aug 2009, 2:27 AM
Hi all
I'm trying to reload a tree panel, saving it's state and then resume the state after the reload but I'm having trouble.

My treepanel is as follow:



var treePanel = new Ext.tree.TreePanel({
id: 'tree-panel',
title: 'x',
region:'center',
split: true,
//minSize: 265,
autoScroll: true,
//height: 265,
// tree-specific configs:
rootVisible: false,
animate: true,
singleExpand: false,
useArrows: true,

stateful: true,
stateEvents: ['click','contextmenu','hide','show','destroy','collapsenode'],


loader: new Ext.tree.TreeLoader({
dataUrl:'http://x/test.php'
})
,root: {
nodeType: 'async',
text: 'x',
draggable: false,
id: 'root_node'
}
,listeners: {
click: function(n) {
Ext.Msg.alert('x', 'Click on: "' + n.attributes.name + '", id: '+n.attributes.id);
}
});


and the code that should reload and restore state is as follow:



var tree = window.top.Ext.getCmp("tree-panel");
var selectedNode = tree.getSelectionModel().getSelectedNode();
var selectedNodePath = selectedNode.getPath();

tree.body.mask('Aggiornamento', 'x-mask-loading');

tree.root.reload();
tree.expandPath(selectedNodePath);

tree.body.unmask();


I'm able to get the selected path just before the reload (selectedNodePath is "filled" correctly), masking is ok, the reload is fine, but I'm unable to get

tree.expandPath(selectedNodePath);
working.

Tree panel is not expanded.

I've even tryied to expand that after 20 seconds (may be that the panel should finish loading befor expand) but nothing change.

alessandro
23 Aug 2009, 11:08 PM
bump

alessandro
25 Aug 2009, 6:26 AM
Please help me...

Ozaki
26 May 2010, 6:51 PM
I have seen this done in v2.x.x - But that plugin no longer works. Anyone know how to get something similar going in 3.x.x?

darthwes
26 May 2010, 8:54 PM
tree.root.reload(function() {
tree.expandPath(selectedNodePath);
});

Doesn't work?