PDA

View Full Version : Ext.tree.Panel : save state of tree



re.tf
4 Jun 2013, 7:00 AM
Hi All,

I have one doubt! I have one 'Ext.tree.Panel' that load data from one ‘Ext.data.TreeStore’ in ajax mode. When user click on + new ajax is sent to server.

For sample:

-01
|
-|-02
|
|-Leaf
+|-Other Folder

The problem is when user chooses, for sample ‘Leaf’. In this case I need change page (redirect)! When user click on back button, my tree is collapsed, like:

+01

I want known one way to restore tree! When user goes back, I want that he see:


-01
|
-|-02
|
|-Leaf
+|-Other Folder

And not:

+01

How I can restore tree (ajax) on page change? Have anyway? Have any way to save a tree in json (in session var, for sample), and then, load it again.

Thanks

slemmon
6 Jun 2013, 11:09 AM
You might look at LocalStorage (http://docs.sencha.com/extjs/4.2.1/#!/api/Ext.data.proxy.LocalStorage) and tree's nodeInterface's serialize (http://docs.sencha.com/extjs/4.2.1/#!/api/Ext.data.NodeInterface-method-serialize) method. You should be able to grab the tree's data as a string using serialize and store it in LocalStorage I'd think.

re.tf
11 Jun 2013, 12:37 PM
Thanks I will take a look!