1. #1
    Sencha User
    Join Date
    Apr 2007
    Posts
    172
    Vote Rating
    1
    medusadelft is on a distinguished road

      0  

    Default [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:

    Code:
    this.getLeaguesStore().filter('id', 2);
    But when I want to look at all records again, I have to find a way to remove the filter.

    Code:
    this.getLeaguesStore().filter();
    doesn't work.

    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.

  2. #2
    Sencha User
    Join Date
    Apr 2007
    Posts
    172
    Vote Rating
    1
    medusadelft is on a distinguished road

      1  

    Default


    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...)

  3. #3
    Sencha User
    Join Date
    Jul 2009
    Posts
    48
    Vote Rating
    0
    ninoguba is on a distinguished road

      0  

    Default 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.

  4. #4
    Sencha User
    Join Date
    Apr 2011
    Posts
    65
    Vote Rating
    1
    c089 is on a distinguished road

      0  

    Default


    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.

  5. #5
    Sencha User
    Join Date
    Jul 2009
    Posts
    48
    Vote Rating
    0
    ninoguba is on a distinguished road

      0  

    Default 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.

    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);
    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.

    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

  1. Replies: 5
    Last Post: 21 Aug 2011, 8:36 PM
  2. [CLOSED-1315] store.filter does not work ?
    By angel.ignacio.colmenares in forum Ext 3.x: Bugs
    Replies: 9
    Last Post: 18 Oct 2010, 8:56 AM
  3. Replies: 4
    Last Post: 27 May 2010, 3:20 PM
  4. [CLOSED] Store filter is not working for LiveGrid
    By kondala in forum Ext GWT: Bugs (2.x)
    Replies: 1
    Last Post: 4 Mar 2010, 1:44 AM
  5. Replies: 1
    Last Post: 8 May 2009, 8:01 AM

Thread Participants: 2