Victor
Victor

Reputation: 17097

EXTjs gridfilter: How to clearfilter without reloading store?

In extjs GridFilters, is there a way to clear the filters without reloading the store?
This is the rquirement:
There is a grid(#1) and another grid(#2) below the grid. The grid(#1) has a list of ids, and when a particular id is clicked, the grid(#2) is popualted with a list of records that belong to that id.
And example might be:grid#1: list of all maangers
grid#2: list of all employees for a particular maanger.

Grid #2 has a filter: on employee name.

The rqmt is: When a selection is changed in grid#1, clear all the old filters, but do not relaod the store for grid #2 as grid#2 store will be loaded through another function.

Please let me know how I can help by providing more info

Upvotes: 1

Views: 9941

Answers (4)

Drew
Drew

Reputation: 1777

After some Firebug stepping, I found this works quite well.

var store = this.getStore();
store.remoteFilter = false;
store.clearFilter();
store.remoteFilter = true;
store.filter(...);

remoteFilter does not seem to be a documented property, but it will suspend xhr calls while it's set to false.

When you set remoteFilter to false, when clearFilter() is called, the load() function is stepped over.

Upvotes: 4

Erik Kaplun
Erik Kaplun

Reputation: 38217

I've experienced the same issue but not with a Grid but with a DataView, however, this might apply equally to your case. I initially tried:

var store = this.getStore();
store.suspendEvents();
store.clearFilter();
store.resumeEvents();
store.filter(...);

this didn't work—still 2 HTTP requests were made, once for clearFilter(), once for filter(...).

However, the following works:

var store = this.getStore();
store.getProxy().extraParams['q'] = keywords;
store.load();

Upvotes: 0

Rob Boerman
Rob Boerman

Reputation: 2168

have you tried temporarily suspending the events on the grid? grid.suspendEvents(); grid.doYourMagic(); grid.resumeEvents();

reloading of the store is most likely triggered by an event anyway.

Upvotes: 0

Abdel Raoof Olakara
Abdel Raoof Olakara

Reputation: 19353

The clearFilters() method available with GridFilter class should be able to clear the filters. Did you give it a try? Also, when does the grid#2 get loaded? according to your first para, when the user select a manager the employees are listed. But in the second para where you stated your requirement, you said the grid#2 is loaded through another function!.. no clear with that though.

Upvotes: 0

Related Questions