ExtJS4
I've created a TreePanel as
var tree = Ext.create('Ext.tree.TreePanel', <some config>);
tree.store.setRootNode(treeJSON);
Now I want to create another tree with the same store data but different store objects. If I do this:
var tree1 = tree.cloneConfig(<separate listeners>);
Then, it creates a different tree. But still both are linked. When I collapse or expand one tree node, the corresponding node in the other tree also behaves similarly.
There is not cloneConfig property for store too so that I can duplicate it. I tried to recreate the store from the JSON for this tree.
var store2 = Ext.create('Ext.data.TreeStore', {store: treeJSON});
var tree1 = tree.cloneConfig({store: store2});
I thought store2
would be different from the tree
s store. But the problem was there since I was using the same treeJSON.
One thing I can do is to convert the JSON into string, decode it to create another JSON object and assign it to the new store. That would be different from the previous store. But there must exist a quick way for that.
How to create a duplicate tree with different store objects so that when I expand/collapse one node in a tree, it does not expand/collapse the same way in the other one?
I have done something similar to this.
Parse your old tree to create a new tree