PDA

View Full Version : [DUP][3.??] GridFilters clashes with ColumnHeaderGroup



tonedeaf
31 Dec 2009, 11:17 AM
GridFilters plugin does not show the "green" filter column background on the correct column header when used with ColumnHeaderGroup plugin.

This is because the function updateColumnHeadings (GridFilters.js) (see bold line):


/**
* Update the styles for the header row based on the active filters
*/
updateColumnHeadings : function () {
var view = this.grid.getView(),
hds, i, len, filter;
if (view.mainHd) {
hds = view.mainHd.select('td').removeClass(this.filterCls);
for (i = 0, len = view.cm.config.length; i < len; i++) {
filter = this.getFilter(view.cm.config[i].dataIndex);
if (filter && filter.active) {
hds.item(i).addClass(this.filterCls);
}
}
}
},

selects the td cells in header in the GridView and applies the css and it incorrectly assumes that there is only one header. The correct approach is to select the td cells from the last header, as ColumnGroupHeader plugin can render multiple headers.

Corrected code in GridFilters.js:


/**
* Update the styles for the header row based on the active filters
*/
updateColumnHeadings : function () {
var view = this.grid.getView(),
hds, i, len, filter;
if (view.mainHd) {
hds = view.mainHd.select('table:last-child td').removeClass(this.filterCls);
for (i = 0, len = view.cm.config.length; i < len; i++) {
filter = this.getFilter(view.cm.config[i].dataIndex);
if (filter && filter.active) {
hds.item(i).addClass(this.filterCls);
}
}
}
},

Condor
2 Jan 2010, 12:30 AM
IMHO it should be:

Ext.override(Ext.ux.grid.GridFilters, {
updateColumnHeadings : function () {
var view = this.grid.getView(),
hds, i, len, filter;
if (view.mainHd) {
hds = view.mainHd.select(view.cellSelector).removeClass(this.filterCls);
for (i = 0, len = view.cm.config.length; i < len; i++) {
filter = this.getFilter(view.cm.config[i].dataIndex);
if (filter && filter.active) {
hds.item(i).addClass(this.filterCls);
}
}
}
}
});

Condor
15 Jan 2010, 1:56 AM
Duplicate of this thread (http://www.extjs.com/forum/showthread.php?t=86037).

Jamie Avins
15 Jan 2010, 10:21 AM
Closing this thread and getting you a bug # for the other.