Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Removing a filter from a store in ExtJS

I explicitly add a filter to a Ext.data.Store using the store.filter(string, string) method.

However, I can not figure out how to remove filters from the store. So the filters always apply even after reloading using store.load(). The only workaround I see is to restart the entire web app.

How do I remove a filter from an Ext.data.Store?

like image 390
joemoe Avatar asked Sep 01 '11 18:09

joemoe


1 Answers

In addition to Mchi's answer, I want to say that it is possible to remove specific filter (clearFilter() removes them all).
To do that, instead of using store.filter('property_to_filter','value') method, use:

store.filters.add('filtersId', new Ext.util.Filter({
  property: 'property_to_filter',
  value: 'value'
}));
store.load();

to remove filter use:

store.filters.removeAtKey('filtersId');

Update (for > 4.2.0)

In 4.2.0 methods for adding/removing specific filter were added:

store.addFilter({
    id: 'filtersId',
    property: 'property_to_filter',
    value: 'value'
});

store.removeFilter('filtersId');

For more info check out docs: Ext.data.Store.addFilter, Ext.data.Store.removeFilter

like image 181
Molecular Man Avatar answered Oct 04 '22 06:10

Molecular Man