Skip to content

Commit 6a61097

Browse files
authored
DataGrid - Filter Row's Reset button does not work after a custom filter is set in Filter Builder (T1267481) (DevExpress#28968)
1 parent 3c2cb90 commit 6a61097

File tree

3 files changed

+56
-3
lines changed

3 files changed

+56
-3
lines changed

e2e/testcafe-devextreme/tests/dataGrid/filterRow/filterRow.ts

Lines changed: 52 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import FilterTextBox from 'devextreme-testcafe-models/dataGrid/editors/filterTex
44
import url from '../../../helpers/getPageUrl';
55
import { createWidget } from '../../../helpers/createWidget';
66
import { changeTheme } from '../../../helpers/changeTheme';
7-
import { getNumberData } from '../helpers/generateDataSourceData';
7+
import { getNumberData, getData } from '../helpers/generateDataSourceData';
88

99
fixture.disablePageReloads`FilterRow`
1010
.page(url(__dirname, '../../container.html'));
@@ -106,3 +106,54 @@ test('FilterRow range overlay screenshot', async (t) => {
106106
applyFilter: 'auto',
107107
},
108108
}));
109+
110+
// T1267481
111+
test('Filter Row\'s Reset button does not work after a custom filter is set in Filter Builder', async (t) => {
112+
const dataGrid = new DataGrid('#container');
113+
const filterEditor = dataGrid.getFilterEditor(0, FilterTextBox);
114+
115+
await dataGrid.isReady();
116+
117+
await t
118+
.expect(dataGrid.dataRows.count)
119+
.eql(0);
120+
121+
await t
122+
.click(filterEditor.menuButton)
123+
.click(filterEditor.menu.getItemByText('Reset'));
124+
125+
await t
126+
.expect(dataGrid.dataRows.count)
127+
.notEql(0);
128+
}).before(async () => {
129+
await createWidget('dxDataGrid', {
130+
dataSource: getData(20, 1),
131+
height: 400,
132+
showBorders: true,
133+
filterRow: {
134+
visible: true,
135+
applyFilter: 'auto',
136+
},
137+
filterBuilder: {
138+
customOperations: [
139+
{
140+
name: 'custom',
141+
caption: 'custom',
142+
dataTypes: ['string'],
143+
icon: 'check',
144+
hasValue: false,
145+
calculateFilterExpression() {
146+
return [
147+
['Field 0', '=', 0],
148+
];
149+
},
150+
},
151+
],
152+
allowHierarchicalFields: true,
153+
},
154+
filterPanel: { visible: true },
155+
filterValue: [
156+
['field_0', 'custom'],
157+
],
158+
});
159+
});

packages/devextreme/js/__internal/grids/grid_core/columns_controller/m_columns_controller_utils.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -681,7 +681,7 @@ export const columnOptionCore = function (that: ColumnsController, column, optio
681681
that._checkColumns();
682682
}
683683

684-
if (!isDefined(prevValue) && !isDefined(value) && optionName.indexOf('buffer') !== 0) {
684+
if (!isDefined(prevValue) && !isDefined(value) && optionName.indexOf('buffer') !== 0 && notFireEvent !== false) {
685685
notFireEvent = true;
686686
}
687687

packages/devextreme/js/__internal/grids/grid_core/filter/m_filter_row.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -622,7 +622,9 @@ const columnHeadersView = (Base: ModuleType<ColumnHeadersView>) => class ColumnH
622622
options[isOnClickMode ? 'bufferedSelectedFilterOperation' : 'selectedFilterOperation'] = column.defaultSelectedFilterOperation || null;
623623
}
624624

625-
that._columnsController.columnOption(column.index, options);
625+
const isResetFilterOperation = !properties.itemData?.name;
626+
const isNotFireEvent = isResetFilterOperation ? false : undefined;
627+
that._columnsController.columnOption(column.index, options, undefined, isNotFireEvent);
626628
that._applyFilterViewController.setHighLight($editorContainer, true);
627629

628630
if (!selectedFilterOperation) {

0 commit comments

Comments
 (0)