-
7 May 2011 12:23 AM #1
[CLOSED] How to remove a store's filter
[CLOSED] How to remove a store's filter
I've added a filter to one of my stores:
But when I want to look at all records again, I have to find a way to remove the filter.Code:this.getLeaguesStore().filter('id', 2);
doesn't work.Code:this.getLeaguesStore().filter();
Of course, I can reload the whole store, but that doesn't seems efficient to me...
Any ideas (I probably overlooked something)?
Thanks in advance,
Maurice.
-
7 May 2011 12:30 AM #2
Found it: clearFilter(). Looked for deleteFilter and removeFilter, but didn't think of this one. I misunderstood the documentation about filter with no properties.
calling filter with no arguments simply re-applies all existing filters. As I don't have any filters defined in my Store, I thought that it returned to the previous state...(so no filtering). Maybe someone can add this to the documentation as well (no info on util.Filter how to remove them...)
-
9 Jun 2011 12:22 PM #3
filter with no arguments doesn't work as i expected
filter with no arguments doesn't work as i expected
I noticed that calling store.filter() with no arguments doesn't seem to re-aapply the filters as the documentation says it would. Looking at the filter() method's source doesn't seem to support this as well.
My understanding is that we can use this method to reapply the filters after we remove any of the existing filters. I agree that reloading the store's data just to reapply the filters is not ideal.
Does anybody came across this already and found a solution?
Thanks.
-
10 Jun 2011 12:07 AM #4
See this thread where I stumbled upon a similar problem. Cloning the filters, clearing them and them reapplying as suggested in this thread should work for you.
-
10 Jun 2011 8:57 AM #5
Similar solution
Similar solution
Thanks for pointing me to that thread! Actually I've already figured out a similar way to do what I needed. Here it is below in case anyone will be interested.
Basically you remove a filter from the store's filters collection, reset the store's data to the clone of the store's snapshot, and then reapply the filters one by one and fire the datachanged event afterwards.Code:var authorizersStore = Ext.getStore('Authorizers'); authorizersStore.filters.removeAt(filterIndex); authorizersStore.data = authorizersStore.snapshot.clone(); authorizersStore.filters.each(function(item, index){ authorizersStore.data = authorizersStore.data.filter(new Ext.util.Filter({ filterFn: function(record) { return isMatch(record,appliedFilters[index+2].getText()); } })); }); authorizersStore.fireEvent('datachanged', authorizersStore);
I noticed that calling filter() passing the array of filters have a different effect than calling filter() passing each item in the store's filters so just take note of this if you have a similar need in your application.
Similar Threads
-
ext.data.store.filter [multiple filter options] i´ts not working
By imegai in forum Ext 3.x: BugsReplies: 5Last Post: 21 Aug 2011, 8:36 PM -
[CLOSED-1315] store.filter does not work ?
By angel.ignacio.colmenares in forum Ext 3.x: BugsReplies: 9Last Post: 18 Oct 2010, 8:56 AM -
[CLOSED][3.x] Ext.form.ComboBox -> lazyInit and store.filter()
By tobiu in forum Ext 3.x: BugsReplies: 4Last Post: 27 May 2010, 3:20 PM -
[CLOSED] Store filter is not working for LiveGrid
By kondala in forum Ext GWT: Bugs (2.x)Replies: 1Last Post: 4 Mar 2010, 1:44 AM -
[CLOSED] [2.0 M1] Filter field not filter DataList with DataListBinder
By Webflash in forum Ext GWT: Bugs (2.x)Replies: 1Last Post: 8 May 2009, 8:01 AM


Reply With Quote