PDA

View Full Version : Single Treestore for multiple treepanels



spits79
7 May 2014, 8:03 AM
Hello,

I have defined a view from treepanel which user a store I extended from an async treestore. This treepanel is used in multiple places but the same data is always used. To minimise network traffic I have deliberately set all the treepanel to have a initComponent function which looks to see if a tree store exists and if I does use the existing tree store, if not then create and use it. I can't use just one component since it is slotted into various different layout with different sizes.

This works fine however it seems that when the store is first connected to the treepanel it is attached and loaded regardless of if the store already has data loaded.

So you can load a treepanel -> it creates and attached the treestore. This then load the first branch and works normally as treepanels do. If you swap to anther screen and a new treepanel is created -> it attaches the existing treestore but then seem to empty the store. So then the second treepanel then loads the treestore and first branch again and this then works too as you would expect any treepanel to.

From this point on they the 2 treepanel use the one store as you would expect; so if you open one branch it is automatically opened on the other treepanel also, (which is what I am after)

I know there is a clearOnLoad config you can set on the treestore but that didn't seem to do anything. It's not the end of the world but is there a way to stop the purge on creation of a new treepanel if it using an existing store?

Cheers,
Ben

mitchellsimoens
19 May 2014, 8:14 AM
I tried to create a simple test case to reproduce but it's working as I expected it to:

5v9

spits79
20 May 2014, 3:26 AM
Hmmm - interestingly if set autoLoad to false the store still loaded without a load call.

Ok so I have a menu item and a "mainWindow" panel for my application. When a users selects a menu item it disconnects the removes the "mainWindow" from the viewport without destroying it and check if the new "main windows" exists if not it creates it and adds it to the viewport if it exists it just adds it to the viewport. After this it fires and "activeview" event

The tree components are items in multiple "mainWindow" panels. I have a listener set that listens for this "activeview" which calls selectPath on the tree (from a cookie value)

treelist is my alias for the class


pickNode : function(me){
var treelist = me.down('treelist');
locPath = Ext.state.Manager.get('assetTreeNodePath', '');
treelist.selectPath(locPath);
}


It seems that selectPath fires a load the first time it's called from a new "mainWindow" panel because watching the browsers network calls once they are both loaded this function is still called every time you swap "mainWindows" and it doesn't make any more network calls.