emilyk
emilyk

Reputation: 713

Extjs Grid Panel Filter - Clear filters only in one column

This question (EXTjs gridfilter: How to clearfilter without reloading store?) shows how to clear all the filters on the entire grid.

Is there a way to clear only the filters in a specific column? For example, if I have a column with a list filter that has 20 options and I select 8 of them, I'd like a button that will uncheck all of those, but leave any other filters I've selected to remain in tact.

The 'size' column on this demo is a good example of what the filtering looks like: http://dev.sencha.com/deploy/ext-4.0.0/examples/grid-filtering/grid-filter-local.html

Upvotes: 2

Views: 3700

Answers (1)

rixo
rixo

Reputation: 25001

You can do it with the setActive method of the filter.

And here's how you can get a reference to this filter:

// FiltersFeature adds a filters property to the grid it is bound to
grid.filters.getFilter('size').setActive(false)

Edit: How to uncheck all boxes

var filter = grid.filters.getFilter('size');
filter.menu.items.each(function(checkbox) {
    // The second argument suppress the check event in order to prevent
    // unexpected behaviour, like the filter reenabling itself and trying
    // to update the store several times in a row
    checkbox.setChecked(false, true);
});

Upvotes: 3

Related Questions