Skip to content

Commit 5eafb86

Browse files
authored
T1272535: DataGrid - fix base sensitivity search in lookup column (#28861)
Co-authored-by: CORP\vladimir.bushmanov <vladimir.bushmanov@devexpress.com>
1 parent 883e56b commit 5eafb86

File tree

4 files changed

+78
-15
lines changed

4 files changed

+78
-15
lines changed

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

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,3 +51,44 @@ safeSizeTest('searchPanel has correct view inside masterDetail', async (t) => {
5151
},
5252
});
5353
}).after(async () => { await changeTheme(Themes.genericLight); });
54+
55+
// T1272535
56+
safeSizeTest('Base sensitivity search should accept rows with accent letters in lookup columns', async (t) => {
57+
const dataGrid = new DataGrid('#container');
58+
59+
await t
60+
.click(dataGrid.getSearchBox().input)
61+
.pressKey('a');
62+
63+
await t.expect(dataGrid.dataRows.count).eql(2);
64+
await t.expect(dataGrid.dataRows.withText('another').exists).ok();
65+
await t.expect(dataGrid.dataRows.withText('ánother').exists).ok();
66+
}, [800, 800]).before(async () => createWidget('dxDataGrid', {
67+
dataSource: {
68+
store: [
69+
{ id: 1, text: 'tešt', lookup: 1 },
70+
{ id: 2, text: 'test', lookup: 2 },
71+
{ id: 3, text: 'chest', lookup: 3 },
72+
],
73+
langParams: {
74+
locale: 'en-US',
75+
collatorOptions: {
76+
sensitivity: 'base',
77+
},
78+
},
79+
},
80+
keyExpr: 'id',
81+
searchPanel: { visible: true },
82+
columns: ['id', 'text', {
83+
dataField: 'lookup',
84+
lookup: {
85+
dataSource: [
86+
{ id: 1, text: 'another' },
87+
{ id: 2, text: 'ánother' },
88+
{ id: 3, text: 'other' },
89+
],
90+
valueExpr: 'id',
91+
displayExpr: 'text',
92+
},
93+
}],
94+
}));

packages/devextreme/js/__internal/grids/grid_core/search/m_search.ts

Lines changed: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
/* eslint-disable max-classes-per-file */
22
/* eslint-disable @typescript-eslint/method-signature-style */
33
import messageLocalization from '@js/common/core/localization/message';
4+
import type { LangParams } from '@js/common/data';
45
import dataQuery from '@js/common/data/query';
56
import domAdapter from '@js/core/dom_adapter';
67
import $ from '@js/core/renderer';
@@ -56,8 +57,11 @@ const dataController = (
5657
}
5758

5859
protected _calculateAdditionalFilter(): Filter {
60+
const dataSource = this._dataController?.getDataSource?.();
61+
const langParams = dataSource?.loadOptions?.()?.langParams;
62+
5963
const filter = super._calculateAdditionalFilter();
60-
const searchFilter = this.calculateSearchFilter(this.option('searchPanel.text'));
64+
const searchFilter = this.calculateSearchFilter(this.option('searchPanel.text'), langParams);
6165

6266
return gridCoreUtils.combineFilters([filter, searchFilter]);
6367
}
@@ -66,8 +70,7 @@ const dataController = (
6670
this.option('searchPanel.text', text);
6771
}
6872

69-
private calculateSearchFilter(text: string | undefined): Filter {
70-
let i;
73+
private calculateSearchFilter(text: string | undefined, langParams?: LangParams): Filter {
7174
let column;
7275
const columns = this._columnsController.getColumns();
7376
const searchVisibleColumnsOnly = this.option('searchPanel.searchVisibleColumnsOnly');
@@ -87,17 +90,33 @@ const dataController = (
8790
}
8891
}
8992

90-
for (i = 0; i < columns.length; i++) {
93+
for (let i = 0; i < columns.length; i++) {
9194
column = columns[i];
9295

9396
if (searchVisibleColumnsOnly && !column.visible) continue;
9497

9598
if (allowSearch(column) && column.calculateFilterExpression) {
9699
lookup = column.lookup;
97100
const filterValue = parseValue(column, text);
98-
if (lookup && lookup.items) {
101+
102+
if (lookup?.items) {
99103
// @ts-expect-error
100-
dataQuery(lookup.items).filter(column.createFilterExpression.call({ dataField: lookup.displayExpr, dataType: lookup.dataType, calculateFilterExpression: column.calculateFilterExpression }, filterValue, null, 'search')).enumerate().done(onQueryDone);
104+
dataQuery(lookup.items, { langParams })
105+
// @ts-expect-error
106+
.filter(
107+
column.createFilterExpression.call(
108+
{
109+
dataField: lookup.displayExpr,
110+
dataType: lookup.dataType,
111+
calculateFilterExpression: column.calculateFilterExpression,
112+
},
113+
filterValue,
114+
null,
115+
'search',
116+
),
117+
)
118+
.enumerate()
119+
.done(onQueryDone);
101120
} else if (filterValue !== undefined) {
102121
filters.push(column.createFilterExpression(filterValue, null, 'search'));
103122
}

packages/devextreme/js/data/data_source.d.ts

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
import {
2-
DataSource,
3-
DataSourceOptions,
4-
FilterDescriptor,
5-
GroupDescriptor,
6-
SearchOperation,
7-
SelectDescriptor,
8-
SortDescriptor,
9-
Store,
10-
StoreOptions,
2+
DataSource,
3+
DataSourceOptions,
4+
FilterDescriptor,
5+
GroupDescriptor,
6+
LangParams,
7+
SearchOperation,
8+
SelectDescriptor,
9+
SortDescriptor,
10+
Store,
11+
StoreOptions,
1112
} from '../common/data';
1213

1314
export {
@@ -40,6 +41,7 @@ export interface DataSourceOptionsStub<
4041
expand?: Array<string> | string;
4142
filter?: FilterDescriptor | Array<FilterDescriptor>;
4243
group?: GroupDescriptor<TItem> | Array<GroupDescriptor<TItem>>;
44+
langParams?: LangParams;
4345
map?: ((dataItem: TStoreItem) => TMappedItem);
4446
onChanged?: ((e: { readonly changes?: Array<TMappedItem> }) => void);
4547
onLoadError?: ((error: { readonly message?: string }) => void);

packages/devextreme/ts/dx.all.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6882,6 +6882,7 @@ declare module DevExpress.data {
68826882
group?:
68836883
| DevExpress.common.data.GroupDescriptor<TItem>
68846884
| Array<DevExpress.common.data.GroupDescriptor<TItem>>;
6885+
langParams?: DevExpress.common.data.LangParams;
68856886
map?: (dataItem: TStoreItem) => TMappedItem;
68866887
onChanged?: (e: { readonly changes?: Array<TMappedItem> }) => void;
68876888
onLoadError?: (error: { readonly message?: string }) => void;

0 commit comments

Comments
 (0)