Uriel
Uriel

Reputation: 464

ExtJs remote (list) filter reset

I have an issue with Extjs remote filter that I excpect you could help to clarify.

I've created a grid with a remote filter that works great, but if I update the grid info, the filter keeps the previous loaded data.

I've tried everything: store.doDestroy, store.removeAll, even assign a new store to the var with Ex.create, but I didn't succeed.

I've created a Fiddle to try to reproduce my issue:

  1. First load default info (Simpsons)
  2. Then open the 'Hobbie' filter (Simulates a select distinct). You get Jazz, Skate, Beer and Knit.
  3. After that, update the grid data (Switch to Van Houtens)
  4. Finally, try to get Van Houtens hobbies (Videogames, Margaritas and None), but you get Simpsons Hobbies (Jazz, Skate..), cause the filter was previously loaded. (Notice how there was not a loading mask).
  5. Now restart the test skipping step 2 (and 5 to avoid infinite loop XD) and notice how the right hobbies are shown.

I need to 'reset' that previous store load.

Notes:

Upvotes: 0

Views: 245

Answers (1)

Fabio Barros
Fabio Barros

Reputation: 1439

You just need to "rebind" the filters for each column like this:

var grid = this.up('grid');

//Clear the current filters before changing
grid.getPlugins()[0].clearFilters();

var store = grid.getStore();
setStoreFilter(store, 'Van Houten');

//Setting the store filters is not enough    
setStoreFilter(filterStore, 'Van Houten');
setStoreFilter(hobbiesStore, 'Van Houten');

//You need to "rebind" the store, it needs a little delay to work properly
setTimeout(function(){ grid.getColumns()[3].filter.bindMenuStore(hobbiesStore); }, 1000);

Here is the updated FIDDLE

Upvotes: 1

Related Questions