Skip to content

Commit

Permalink
DataGrid: Fix display of only relevant values for lookup in filter ro…
Browse files Browse the repository at this point in the history
…w when filter panel is enabled (T1192700) (#25774)

Co-authored-by: Alyar <>
  • Loading branch information
Alyar666 authored Oct 10, 2023
1 parent b8afab5 commit 73957b0
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 11 deletions.
24 changes: 13 additions & 11 deletions js/__internal/grids/grid_core/filter/m_filter_sync.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
41 changes: 41 additions & 0 deletions testing/tests/DevExpress.ui.widgets.dataGrid/filterRow.tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit 73957b0

Please sign in to comment.