Skip to content

Commit fe70ac2

Browse files
committed
cover unbound column case
1 parent 0200e61 commit fe70ac2

File tree

2 files changed

+35
-2
lines changed

2 files changed

+35
-2
lines changed

e2e/testcafe-devextreme/tests/dataGrid/common/grouping/grouping.ts

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -320,7 +320,38 @@ test('DataGrid should not lose grouping after the expandAll method if a grouped
320320
'b', 'c'],
321321
}));
322322

323-
test('DataGrid should not change group column after the expandAll method if a grouped column has string calculateGroupValue (T1308536)', async (t) => {
323+
test('DataGrid should not change group column after the expandAll method, string calculateGroupValue corresponds another column (T1308536)', async (t) => {
324+
const dataGrid = new DataGrid('#container');
325+
const firstGroupCellText = await dataGrid.getGroupRow(0).getCell(1).element.textContent;
326+
327+
await dataGrid.apiExpandAll();
328+
329+
await t
330+
.expect(dataGrid.apiColumnOption('a', 'groupIndex'))
331+
.eql(0)
332+
.expect(dataGrid.apiColumnOption('aLabel', 'groupIndex'))
333+
.eql(undefined)
334+
.expect(dataGrid.getGroupRow(0).getCell(1).element.textContent)
335+
.eql(firstGroupCellText);
336+
}).before(async () => createWidget('dxDataGrid', {
337+
dataSource: [{
338+
id: 0, a: 0, aLabel: 'A_0', b: 'B_0', c: 'C_0',
339+
}],
340+
keyExpr: 'id',
341+
grouping: { autoExpandAll: false },
342+
columns: [{
343+
dataField: 'a',
344+
groupIndex: 0,
345+
calculateGroupValue: 'aLabel',
346+
},
347+
{
348+
caption: 'aLabel',
349+
calculateCellValue(data) { return data.aLabel; },
350+
},
351+
'b', 'c'],
352+
}));
353+
354+
test('DataGrid should not change group column after the expandAll method, , string calculateGroupValue corresponds another unbound column (T1308536)', async (t) => {
324355
const dataGrid = new DataGrid('#container');
325356
const firstGroupCellText = await dataGrid.getGroupRow(0).getCell(1).element.textContent;
326357

packages/devextreme/js/__internal/grids/grid_core/columns_controller/m_columns_controller.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1341,7 +1341,9 @@ export class ColumnsController extends modules.Controller {
13411341

13421342
each(columns, (_: number, column) => {
13431343
const isReferencedAsGroupValue = indexParameterName === 'groupIndex'
1344-
&& referencedGroupValues.includes(column.dataField);
1344+
&& referencedGroupValues.some((groupValue) => column.dataField === groupValue
1345+
|| column.name === groupValue
1346+
|| gridCoreUtils.isSelectorEqualWithCallback(groupValue, column.calculateCellValue));
13451347

13461348
if (!isReferencedAsGroupValue) {
13471349
// eslint-disable-next-line @typescript-eslint/no-dynamic-delete

0 commit comments

Comments
 (0)