Skip to content

Commit

Permalink
Merge branch '23_1' of https://github.com/DevExpress/DevExtreme into …
Browse files Browse the repository at this point in the history
…23_1
  • Loading branch information
nikkithelegendarypokemonster committed Jul 17, 2024
2 parents 4703b4d + 361a70a commit 4822481
Show file tree
Hide file tree
Showing 2 changed files with 91 additions and 14 deletions.
50 changes: 36 additions & 14 deletions js/__internal/grids/grid_core/column_fixing/m_column_fixing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,25 +91,47 @@ const baseFixedColumns = <T extends ModuleType<ColumnsView>>(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) {
Expand Down
55 changes: 55 additions & 0 deletions testing/testcafe/tests/dataGrid/fixedColumns.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
},
],
}));

0 comments on commit 4822481

Please sign in to comment.