In my application, I would like to provide two stores for one tree panel.
When user click a button on the tbar, the tree panel will show another store.
I wonder if it's possible to change the store dynamically for a tree panel.
Thanks in advance!
In my application, I would like to provide two stores for one tree panel.
When user click a button on the tbar, the tree panel will show another store.
I wonder if it's possible to change the store dynamically for a tree panel.
Thanks in advance!
Why not just load the store new the new data?
Scott.
scottmartin, thanks for the reply.
But it seems doesn't work for me.
See the example below.
When I click the button, the tree doesn't show store2.Code:Ext.define('myTreePanel', { extend : 'Ext.tree.Panel', initComponent : function() { var me = this; me.store = Ext.getStore('store1'); me.tools = [ { tooltip : 'change store', handler : function(event, target, owner, tool) { me.store = Ext.getStore('store2'); } }]; me.callParent(arguments); } });
Can I just call
to change store dynamically for a tree panel ?Code:me.store = Ext.getStore('store2');
Ext.util.Bindable provides bindStore. It works fine when I use itemselector.
My itemselector is able to change store dynamically by using bindStore.
But treePanel doesn't inherite from Ext.util.Bindable.
How can I make treePanel possible to bind another store?
Best,
cwtuan
The new version is below.
The first store will be replaced with second one. And the tree shows correctly.Code:Ext.define('myTreePanel', { extend : 'Ext.tree.Panel', initComponent : function() { var me = this; me.store = Ext.getStore('store1'); me.tools = [ { tooltip : 'change store', handler : function(event, target, owner, tool) { // me.store = Ext.getStore('store2'); // -> this doesn't work me.setRootNode(Ext.getStore('store2').getRootNode()); } }]; me.callParent(arguments); } });
But When I expand the nodes, firebug show error message
Code:records[i] is undefined ns[i].viewRecordId = records[i].internalId;It seems that the index in tree structure is broken.
PS: I make sure the nodes in store1 and store2 has unique id.