The fastest way to clean a filter from ExtJs storage when applying a filter using filterBy ()

I am using ExtJS 4.1. I use clearFilter() stores to remove the filter from the store. I apply a filter to the store using the filterBy method. I filter all entries where the name is not Ronaldo.

After cleaning the filter, load the view that contains the grid (attached to the repository). But when I load the grid, I still see that the filter is not cleared. A store is a local store. I did not use any groupings in the store. The store uses only one model.

 myStore.filterBy(function (record) { if (record.get('Name') != 'Ronaldo') { return true; } }); 

So far, everything is working fine, but when I clear the filter with clearFilter() , it takes some time. Is there a faster \ better \ correct way to clean the filter in the store when the filter is applied using filterBy() ?

+8
javascript extjs extjs-stores
source share
3 answers

When you use clearFilter() , it does not matter if you used filterBy() or filter() or filters were configured in the repository.

Here's what happens when you clean the filters:

  • empty the filter collection in the repository
  • filtered data is replaced with the original (unfiltered) data that was saved in the snapshot
  • events "datachanged" and "refresh" are triggered in the repository

Note that you can suppress events that will be fired with clearFilter(true) , which can be useful if you want to filter the repository again after clearing the existing filters.

If cleaning the storage filters is slow, then this is probably due to the build process (on your grid or what you use the storage with), which starts in step 3.

Also see docs or source code .

+11
source share

Here is my best answer to clear the filterBy function:

  myStore.filterBy(function (record) { return true; }); 

I just did it, hope his help

+3
source share

Just call a:

 myStore.reload(); 

whenever you want to remove a filter set with filterBy.

0
source share

All Articles