From 73957b07ba443eae31154c60086a7cda99812d49 Mon Sep 17 00:00:00 2001 From: Alyar Date: Tue, 10 Oct 2023 10:37:40 +0400 Subject: [PATCH] DataGrid: Fix display of only relevant values for lookup in filter row when filter panel is enabled (T1192700) (#25774) Co-authored-by: Alyar <> --- .../grids/grid_core/filter/m_filter_sync.ts | 24 ++++++----- .../filterRow.tests.js | 41 +++++++++++++++++++ 2 files changed, 54 insertions(+), 11 deletions(-) diff --git a/js/__internal/grids/grid_core/filter/m_filter_sync.ts b/js/__internal/grids/grid_core/filter/m_filter_sync.ts index 30828a166fcd..2c70a20fd177 100644 --- a/js/__internal/grids/grid_core/filter/m_filter_sync.ts +++ b/js/__internal/grids/grid_core/filter/m_filter_sync.ts @@ -248,23 +248,25 @@ const DataControllerFilterSyncExtender = { }, _calculateAdditionalFilter() { - const that = this; - - if (that.option('filterPanel.filterEnabled') === false) { - return that.callBase(); + if (this.option('filterPanel.filterEnabled') === false) { + return this.callBase(); } - const filters = [that.callBase()]; - const columns = that.getController('columns').getFilteringColumns(); - let filterValue = that.option('filterValue'); + const filters = [this.callBase()]; + const columns = this.getController('columns').getFilteringColumns(); + let filterValue = this.option('filterValue'); + + if (this.isFilterSyncActive()) { + const currentColumnForHeaderFilter = this.getController('headerFilter').getCurrentColumn(); + const currentColumnForFilterRow = this.getController('applyFilter').getCurrentColumnForFiltering(); + const currentColumn = currentColumnForHeaderFilter || currentColumnForFilterRow; + const needRemoveCurrentColumnFilter = currentColumnForHeaderFilter || isDefined(currentColumnForFilterRow?.filterValue); - if (that.isFilterSyncActive()) { - const currentColumn = that.getController('headerFilter').getCurrentColumn(); - if (currentColumn && filterValue) { + if (needRemoveCurrentColumnFilter && filterValue) { filterValue = removeFieldConditionsFromFilter(filterValue, getColumnIdentifier(currentColumn)); } } - const customOperations = that.getController('filterSync').getCustomFilterOperations(); + const customOperations = this.getController('filterSync').getCustomFilterOperations(); const calculatedFilterValue = getFilterExpression(filterValue, columns, customOperations, 'filterBuilder'); if (calculatedFilterValue) { filters.push(calculatedFilterValue); diff --git a/testing/tests/DevExpress.ui.widgets.dataGrid/filterRow.tests.js b/testing/tests/DevExpress.ui.widgets.dataGrid/filterRow.tests.js index b4e9bc944771..0e1e71108548 100644 --- a/testing/tests/DevExpress.ui.widgets.dataGrid/filterRow.tests.js +++ b/testing/tests/DevExpress.ui.widgets.dataGrid/filterRow.tests.js @@ -1341,6 +1341,7 @@ QUnit.module('Filter Row with real dataController and columnsController', { filterRow: { visible: true, showOperationChooser: true, + showAllText: '(All)', operationDescriptions: { 'equal': 'Equals', 'notEqual': 'Not equals', @@ -2807,6 +2808,46 @@ QUnit.module('Filter Row with real dataController and columnsController', { assert.equal(this.columnHeadersView.element().find('.dx-menu-item').first().attr('aria-label'), 'Search box'); }); + // T1192700 + QUnit.test('Lookup select box should not show only relevant values for the current filtered column when filterSyncEnabled is true', function(assert) { + // arrange + const $testElement = $('#container'); + + this.options.columns = [{ + dataField: 'column1', + allowFiltering: true, + filterValue: 1, + lookup: { + dataSource: [{ id: 1, value: 'value1' }, { id: 2, value: 'value2' }], + valueExpr: 'id', + displayExpr: 'value' + } + }]; + this.options.dataSource = [ + { column1: 1 }, + { column1: 2 }, + ]; + this.options.syncLookupFilterValues = true; + this.options.filterSyncEnabled = true; + + setupDataGridModules(this, ['data', 'columns', 'columnHeaders', 'filterRow', 'headerFilter', 'editorFactory', 'filterSync', 'filterBuilder', 'filterPanel'], { + initViews: true + }); + this.columnHeadersView.render($testElement); + + // act + const dropDown1 = $('.dx-dropdowneditor-button').eq(0); + + dropDown1.trigger('dxclick'); + + // assert + const dropDownList1 = $('.dx-list').eq(0); + assert.strictEqual(dropDownList1.find('.dx-item').length, 3); + assert.strictEqual(dropDownList1.find('.dx-item').eq(0).text(), '(All)'); + assert.strictEqual(dropDownList1.find('.dx-item').eq(1).text(), 'value1'); + assert.strictEqual(dropDownList1.find('.dx-item').eq(2).text(), 'value2'); + }); + if(device.deviceType === 'desktop') { // T306751 QUnit.testInActiveWindow('Filter range - keyboard navigation', function(assert) {