Skip to content

Commit 2a5d909

Browse files
authored
DataGrid - getSelectedRowKeys method returns incorrect keys if deferred selection is enabled (T1280037) (DevExpress#29929)
1 parent c7ad287 commit 2a5d909

File tree

3 files changed

+49
-8
lines changed

3 files changed

+49
-8
lines changed

packages/devextreme/js/__internal/ui/selection/m_selection.strategy.deferred.ts

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -69,19 +69,14 @@ export default class DeferredStrategy extends SelectionStrategy {
6969
}
7070

7171
isItemKeySelected(itemData) {
72-
const { selectionFilter, sensitivity } = this.options;
72+
const { selectionFilter } = this.options;
7373

7474
if (!selectionFilter) {
7575
return true;
7676
}
7777

78-
const queryParams = {
79-
langParams: {
80-
collatorOptions: {
81-
sensitivity,
82-
},
83-
},
84-
};
78+
const queryParams = this._getQueryParams();
79+
8580
// @ts-expect-error
8681
return !!dataQuery([itemData], queryParams).filter(selectionFilter).toArray().length;
8782
}

packages/devextreme/js/__internal/ui/selection/m_selection.strategy.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,13 +137,32 @@ export default class SelectionStrategy {
137137
return remoteFilter;
138138
}
139139

140+
_getQueryParams() {
141+
const { sensitivity } = this.options;
142+
143+
if (!sensitivity) {
144+
return;
145+
}
146+
147+
return {
148+
langParams: {
149+
collatorOptions: {
150+
sensitivity,
151+
},
152+
},
153+
};
154+
}
155+
140156
_loadFilteredData(remoteFilter, localFilter?: any, select?: any, isSelectAll?: boolean) {
141157
const filterLength = encodeURI(JSON.stringify(this._removeTemplateProperty(remoteFilter))).length;
142158
const needLoadAllData = this.options.maxFilterLengthInRequest && (filterLength > this.options.maxFilterLengthInRequest);
143159
const deferred = Deferred();
160+
const queryParams = this._getQueryParams();
161+
144162
const loadOptions = {
145163
filter: needLoadAllData ? undefined : remoteFilter,
146164
select: needLoadAllData ? this.options.dataFields() : select || this.options.dataFields(),
165+
...queryParams,
147166
};
148167

149168
if (remoteFilter && remoteFilter.length === 0) {

packages/devextreme/testing/tests/DevExpress.ui.widgets.dataGrid/selection.tests.js

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4643,6 +4643,33 @@ QUnit.module('Deferred selection', {
46434643
// assert
46444644
assert.deepEqual(this.option('selectionFilter'), []);
46454645
});
4646+
4647+
QUnit.test('DataGrid - getSelectedRowKeys method should return correct keys if deferred selection.sensitivity is "variant" (T1280037)', function(assert) {
4648+
this.setupDataGrid({
4649+
dataSource: [
4650+
{ ID: 'aaa', Name: 'Name a' },
4651+
{ ID: 'AAA', Name: 'Name A' },
4652+
],
4653+
keyExpr: 'ID',
4654+
columns: ['ID', 'Name'],
4655+
showBorders: true,
4656+
selection: {
4657+
sensitivity: 'variant',
4658+
mode: 'multiple',
4659+
deferred: true,
4660+
},
4661+
selectionFilter: ['ID', '=', 'aaa'],
4662+
});
4663+
4664+
let selectedRowKeys = [];
4665+
4666+
this.getSelectedRowKeys().done((keys) => {
4667+
selectedRowKeys = keys;
4668+
});
4669+
this.clock.tick();
4670+
4671+
assert.deepEqual(selectedRowKeys, ['aaa'], 'selection filter is case sensitive');
4672+
});
46464673
});
46474674

46484675
QUnit.module('Selection with virtual scrolling', {

0 commit comments

Comments
 (0)