Skip to content

Commit

Permalink
T1272535: DataGrid - fix base sensitivity search in lookup column (#2…
Browse files Browse the repository at this point in the history
…8751)

Co-authored-by: CORP\vladimir.bushmanov <[email protected]>
  • Loading branch information
Ambrozy and CORP\vladimir.bushmanov committed Jan 29, 2025
1 parent 08e27cd commit d05f5b0
Show file tree
Hide file tree
Showing 4 changed files with 78 additions and 15 deletions.
41 changes: 41 additions & 0 deletions e2e/testcafe-devextreme/tests/dataGrid/searchPanel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,3 +51,44 @@ safeSizeTest('searchPanel has correct view inside masterDetail', async (t) => {
},
});
}).after(async () => { await changeTheme(Themes.genericLight); });

// T1272535
safeSizeTest('Base sensitivity search should accept rows with accent letters in lookup columns', async (t) => {
const dataGrid = new DataGrid('#container');

await t
.click(dataGrid.getSearchBox().input)
.pressKey('a');

await t.expect(dataGrid.dataRows.count).eql(2);
await t.expect(dataGrid.dataRows.withText('another').exists).ok();
await t.expect(dataGrid.dataRows.withText('ánother').exists).ok();
}, [800, 800]).before(async () => createWidget('dxDataGrid', {
dataSource: {
store: [
{ id: 1, text: 'tešt', lookup: 1 },
{ id: 2, text: 'test', lookup: 2 },
{ id: 3, text: 'chest', lookup: 3 },
],
langParams: {
locale: 'en-US',
collatorOptions: {
sensitivity: 'base',
},
},
},
keyExpr: 'id',
searchPanel: { visible: true },
columns: ['id', 'text', {
dataField: 'lookup',
lookup: {
dataSource: [
{ id: 1, text: 'another' },
{ id: 2, text: 'ánother' },
{ id: 3, text: 'other' },
],
valueExpr: 'id',
displayExpr: 'text',
},
}],
}));
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/* eslint-disable max-classes-per-file */
/* eslint-disable @typescript-eslint/method-signature-style */
import messageLocalization from '@js/common/core/localization/message';
import type { LangParams } from '@js/common/data';
import dataQuery from '@js/common/data/query';
import domAdapter from '@js/core/dom_adapter';
import $ from '@js/core/renderer';
Expand Down Expand Up @@ -56,8 +57,11 @@ const dataController = (
}

protected _calculateAdditionalFilter(): Filter {
const dataSource = this._dataController?.getDataSource?.();
const langParams = dataSource?.loadOptions?.()?.langParams;

const filter = super._calculateAdditionalFilter();
const searchFilter = this.calculateSearchFilter(this.option('searchPanel.text'));
const searchFilter = this.calculateSearchFilter(this.option('searchPanel.text'), langParams);

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

private calculateSearchFilter(text: string | undefined): Filter {
let i;
private calculateSearchFilter(text: string | undefined, langParams?: LangParams): Filter {
let column;
const columns = this._columnsController.getColumns();
const searchVisibleColumnsOnly = this.option('searchPanel.searchVisibleColumnsOnly');
Expand All @@ -87,17 +90,33 @@ const dataController = (
}
}

for (i = 0; i < columns.length; i++) {
for (let i = 0; i < columns.length; i++) {
column = columns[i];

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

if (allowSearch(column) && column.calculateFilterExpression) {
lookup = column.lookup;
const filterValue = parseValue(column, text);
if (lookup && lookup.items) {

if (lookup?.items) {
// @ts-expect-error
dataQuery(lookup.items).filter(column.createFilterExpression.call({ dataField: lookup.displayExpr, dataType: lookup.dataType, calculateFilterExpression: column.calculateFilterExpression }, filterValue, null, 'search')).enumerate().done(onQueryDone);
dataQuery(lookup.items, { langParams })
// @ts-expect-error
.filter(
column.createFilterExpression.call(
{
dataField: lookup.displayExpr,
dataType: lookup.dataType,
calculateFilterExpression: column.calculateFilterExpression,
},
filterValue,
null,
'search',
),
)
.enumerate()
.done(onQueryDone);
} else if (filterValue !== undefined) {
filters.push(column.createFilterExpression(filterValue, null, 'search'));
}
Expand Down
20 changes: 11 additions & 9 deletions packages/devextreme/js/data/data_source.d.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
import {
DataSource,
DataSourceOptions,
FilterDescriptor,
GroupDescriptor,
SearchOperation,
SelectDescriptor,
SortDescriptor,
Store,
StoreOptions,
DataSource,
DataSourceOptions,
FilterDescriptor,
GroupDescriptor,
LangParams,
SearchOperation,
SelectDescriptor,
SortDescriptor,
Store,
StoreOptions,
} from '../common/data';

export {
Expand Down Expand Up @@ -40,6 +41,7 @@ export interface DataSourceOptionsStub<
expand?: Array<string> | string;
filter?: FilterDescriptor | Array<FilterDescriptor>;
group?: GroupDescriptor<TItem> | Array<GroupDescriptor<TItem>>;
langParams?: LangParams;
map?: ((dataItem: TStoreItem) => TMappedItem);
onChanged?: ((e: { readonly changes?: Array<TMappedItem> }) => void);
onLoadError?: ((error: { readonly message?: string }) => void);
Expand Down
1 change: 1 addition & 0 deletions packages/devextreme/ts/dx.all.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6882,6 +6882,7 @@ declare module DevExpress.data {
group?:
| DevExpress.common.data.GroupDescriptor<TItem>
| Array<DevExpress.common.data.GroupDescriptor<TItem>>;
langParams?: DevExpress.common.data.LangParams;
map?: (dataItem: TStoreItem) => TMappedItem;
onChanged?: (e: { readonly changes?: Array<TMappedItem> }) => void;
onLoadError?: (error: { readonly message?: string }) => void;
Expand Down

0 comments on commit d05f5b0

Please sign in to comment.