PDA

View Full Version : [FIXED] GridFilters with custom filters



bob4ever
3 Jun 2014, 1:54 AM
Hey. I found a bug with the actual ExtJS 5.0.0.970. I have a grid with the gridFilters plugin. Additional to this the grid has some buttons on the top bar which can set a special filter. These filter has an own name which doesn't match to any column in there. My backend to the store has the knowledge what to do with this special filter. When I now want to remove the special filter the grid filters plugin throw an error:

https://fiddle.sencha.com/#fiddle/6a9

To reproduce the error just click the first button "set filter" and then the button "removeFilter" and you should see the error "TypeError: columnManager.getHeaderByDataIndex(...) is null".

I already found the error. The error is found in the GridFilters::onFilterRemove. It's just a missing check whether the column exists before using ".filter" on it. My overwrite for this is:



Ext.define('GridFiltersFix', {
override: 'Ext.grid.filters.Filters',

onFilterRemove: function (filterCollection, list) {
// We need to know when a store filter has been removed by an operation of the gridfilters UI, i.e.,
// store.clearFilter(). The settingValue flag lets us know whether or not this listener has been
// reached by a filter operation (settingValue === true) or by something outside of the UI
// (settingValue === undefined).
var len = list.items.length,
columnManager = this.grid.columnManager,
i, item, header, filter;

for (i = 0; i < len; i++) {
item = list.items[i];

header = columnManager.getHeaderByDataIndex(item.getProperty());
if (!header) {
continue;
}

filter = header.filter;

if (!filter.settingValue) {
// This is only called on the filter if called from outside of the gridfilters UI.
filter.onFilterRemove(item.getOperator());
}
}
}
});

evant
3 Jun 2014, 2:31 AM
Thanks for the report! I have opened a bug in our bug tracker.