diff --git a/js/__internal/grids/grid_core/column_fixing/m_column_fixing.ts b/js/__internal/grids/grid_core/column_fixing/m_column_fixing.ts index 8b8c560f3a2a..b367c24b5280 100644 --- a/js/__internal/grids/grid_core/column_fixing/m_column_fixing.ts +++ b/js/__internal/grids/grid_core/column_fixing/m_column_fixing.ts @@ -91,25 +91,47 @@ const baseFixedColumns = >(Base: T) => class B return super._createCol(column).toggleClass(FIXED_COL_CLASS, !!(this._isFixedTableRendering && (column.fixed || column.command && column.command !== COMMAND_TRANSPARENT))); } + private isIndicesArray(arr): boolean { + return Array.isArray(arr) && arr.length > 0; + } + private _correctColumnIndicesForFixedColumns(fixedColumns, change) { + const columnIndicesArray = change?.columnIndices; + if (!this.isIndicesArray(columnIndicesArray)) { + return; + } + const transparentColumnIndex = getTransparentColumnIndex(fixedColumns); const transparentColspan = fixedColumns[transparentColumnIndex].colspan; - const columnIndices = change && change.columnIndices; + const transparentOffset = transparentColumnIndex + transparentColspan; + const rowTypes = change?.items?.map(({ rowType }) => rowType); - if (columnIndices) { - change.columnIndices = columnIndices.map((columnIndices) => { - if (columnIndices) { - return columnIndices.map((columnIndex) => { - if (columnIndex < transparentColumnIndex) { - return columnIndex; - } if (columnIndex >= transparentColumnIndex + transparentColspan) { - return columnIndex - transparentColspan + 1; - } - return -1; - }).filter((columnIndex) => columnIndex >= 0); + change.columnIndices = columnIndicesArray.map((columnIndices, idx) => { + if (!this.isIndicesArray(columnIndices)) { + return columnIndices; + } + + const isGroupRow = rowTypes && rowTypes[idx] === 'group'; + + if (isGroupRow) { + return [...columnIndices]; + } + + return columnIndices.reduce((result, colIdx) => { + switch (true) { + case colIdx < transparentColumnIndex: + result.push(colIdx); + break; + case colIdx >= transparentOffset: + result.push(colIdx - transparentColspan + 1); + break; + default: + break; } - }); - } + + return result; + }, []); + }); } private _partialUpdateFixedTable(fixedColumns) { diff --git a/testing/testcafe/tests/dataGrid/fixedColumns.ts b/testing/testcafe/tests/dataGrid/fixedColumns.ts index 1710af361f70..ce5496df4390 100644 --- a/testing/testcafe/tests/dataGrid/fixedColumns.ts +++ b/testing/testcafe/tests/dataGrid/fixedColumns.ts @@ -360,3 +360,58 @@ safeSizeTest('The grid layout should be correct after resizing the window when t width: 50, }], })); + +test('DataGrid - Group summary is not updated when a column is fixed on the right side (T1223764)', async (t) => { + const dataGrid = new DataGrid('#container'); + const editCell = dataGrid.getDataRow(1).getDataCell(2); + + await t + .click(editCell.element) + .typeText(editCell.getEditor().element, '5', { replace: true }) + .pressKey('enter') + .expect(dataGrid.getGroupRow(0).element.textContent) + .eql('A: group 0 (Count: 3, Sum of B is 7)'); +}).before(async () => createWidget('dxDataGrid', { + dataSource: [ + { id: 0, A: 'group 0', B: 1 }, + { id: 1, A: 'group 0', B: 1 }, + { id: 2, A: 'group 0', B: 1 }, + ], + keyExpr: 'id', + repaintChangesOnly: true, + columnFixing: { enabled: true }, + groupPanel: { + visible: true, + }, + summary: { + recalculateWhileEditing: true, + groupItems: [ + { + column: 'B', + summaryType: 'count', + }, + { + column: 'B', + summaryType: 'sum', + }, + ], + }, + editing: { + mode: 'cell', + allowUpdating: true, + allowAdding: true, + allowDeleting: true, + }, + columns: [ + { + dataField: 'id', + width: 50, + }, { + dataField: 'A', + groupIndex: 0, + }, { + dataField: 'B', + dataType: 'number', + }, + ], +}));