PDA

View Full Version : STORE / TREE STORE : Whata a filter is really supposed to do ?



near
29 Nov 2011, 8:57 AM
Hi,

I tried to apply a filter to a tree store as shown below:


Ext.define('KECM.store.SitesStore', {
extend: 'Ext.data.TreeStore',


model: 'KECM.model.SitesModel',
autoLoad: true,
filters: [
{ property: 'text', value: 'Accueil'}
],
id: 'sitesStore',


proxy: {
type: 'ajax',
url: 'data/Sites.json'
}
});


But It didn't have any effect. Actually I thougth, only the nodes with the text value : 'Accueil', will be displaid in my tree panel. On the other hand when I checked, I saw one of the sencha example similar to a sorter (http://docs.sencha.com/ext-js/4-0/#!/example/grid-filtering/grid-filter-local.html).

Now I am confused about what a filter does. And the other question is if my code is right ?

Thank's in advance

Regards

Near

mitchellsimoens
29 Nov 2011, 11:08 AM
A filter (if local) will copy the original data set to the snapshot property of the store and the data set in the data property will be iterated through to be filtered. Those that match the filter will remain, those that do not will be removed (still in the snapshot).

Now in TreeStore, I do not believe the tree is refreshed when a filter or a sort happens. Something I believe we are aware of.

near
30 Nov 2011, 1:21 AM
Dear Michell,

I am not trying to refresh a tree. Till now I am just trying to test the property and it's no working. The idea is to use it after, not to refresh a tree, but to add the filter before creating a new tree.


A filter (if local) will copy the original data set to the snapshot property of the store and the data set in the data property will be iterated through to be filtered. Those that match the filter will remain, those that do not will be removed (still in the snapshot).

Now in TreeStore, I do not believe the tree is refreshed when a filter or a sort happens. Something I believe we are aware of.

sheep-allegro
7 Dec 2011, 2:36 AM
Is there any way to refresh the tree after applying a filter to its treestore?

tobiu
7 Dec 2011, 2:57 AM
http://docs.sencha.com/ext-js/4-0/#!/api/Ext.data.Store-method-clearFilter

sheep-allegro
7 Dec 2011, 3:45 AM
"Revert to a view of the Record cache with no filtering applied." -- that doesn't exactly do what I meant by "refresh the tree panel after a filter has been applied to its treestore". I wanted to have the tree redrawn to reflect the filtering that has been applied. What you suggested will remove the filters. Sure, that will make the displayed tree once again match the store, but will defeat the whole purpose of applying a filter.