View Full Version : Filtering on treepanel level instead of treestore level

10 Jan 2011, 4:51 AM

I'm trying to create 2 different treepanels that share the same treestore. One treepanel should only show models with a certain property while the other treepanel should display them all.

Is there a way to easily implement this? So far I've only found that that filter only works on store level, which means that my panels are both filtered. So my question is:

Is there a way to filter on (tree)panel level if not, how would be the best way to tackle this problem? Perhaps there is an easy way to enable/disable store filters dynamically when a treepanel requests data from a store?

10 Jan 2011, 1:18 PM
No There is not. You will need to have two TreeStores, but both can share the same data.

11 Jan 2011, 1:46 AM
Is there a way I can tell the treestore to share the same data? I can let them share the same dataloader but how do I let them share the same fetched data?

11 Jan 2011, 12:41 PM
I would not use a loader at all for this.

Simple get the data manually and add the same instances to both stores.

17 Jan 2011, 4:55 AM
OK I can see how this sounds straightforward if you have static data but unfortunately that's not the case. Both tree panels can be edited (new, delete, move, ...) and changes should be visible in both panels.

This requires that stores listen to each other for changes and act accordingly so they stay in sync. Unfortunately I've encountered the following caveat:

Both treepanels are async treepanels with a dataloader. Each store listens to other stores and updates itself with the changed/new/deleted data from the changed store. This works pretty well. A problem arises when an async treepanel has a node item that has a state "loaded" set to false (=it's never been expanded before) while it's treestore does have the data actually loaded (through it's store 'sync' listener). This causes an unnecessary call to the back-end and fires an unnecessary store changed event (which in turn causes weird things to happen).
Is there a way that I can fix this?

In essence, I would really like to use a single store for both treepanels to avoid all this syncing. However with the current filter implementation on store level, this seems to be impossible to avoid.

17 Jan 2011, 1:03 PM
Is there a way that I can fix this?
You can use JSNI to acces this private member and set it to true manually.