Skip to content

Commit f1216d6

Browse files
DataGrid - Summary values in the fixed column disappear when virtual scrolling and grouping are used (T1221369) (#27642)
Co-authored-by: williamvinogradov <williamvinogradov@gmail.com>
1 parent 7fe1eb5 commit f1216d6

5 files changed

Lines changed: 84 additions & 12 deletions

File tree

26.2 KB
Loading
26 KB
Loading
26.2 KB
Loading

‎e2e/testcafe-devextreme/tests/dataGrid/virtualColumns.ts‎

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -288,3 +288,63 @@ test('Columns should be rendered correctly after reinit of columns controller',
288288
columnRenderingMode: 'virtual',
289289
},
290290
}));
291+
292+
test('Group row should have right colspan with summary, virtual columns and fixed columns (T1221369)', async (t) => {
293+
const grid = new DataGrid('#container');
294+
const { takeScreenshot, compareResults } = createScreenshotsComparer(t);
295+
296+
await takeScreenshot('T1221369_fixed-summary-with-virtual-cols_0.png', grid.element);
297+
298+
// NOTE: There is an issue with Scrollable
299+
// So, we should scroll two times to reach maximum right scroll position
300+
await grid.scrollTo(t, { x: 10000 });
301+
await grid.scrollTo(t, { x: 10000 });
302+
303+
await takeScreenshot('T1221369_fixed-summary-with-virtual-cols_1.png', grid.element);
304+
305+
await grid.scrollTo(t, { x: 0 });
306+
307+
await takeScreenshot('T1221369_fixed-summary-with-virtual-cols_2.png', grid.element);
308+
309+
await t.expect(compareResults.isValid())
310+
.ok(compareResults.errorMessages());
311+
}).before(async () => {
312+
const generatedColumns = generateColumns(20);
313+
const columns = [
314+
{
315+
...generatedColumns[0],
316+
groupIndex: 0,
317+
},
318+
{
319+
...generatedColumns[1],
320+
fixed: true,
321+
},
322+
{
323+
...generatedColumns[2],
324+
fixed: true,
325+
},
326+
...generatedColumns.splice(3),
327+
];
328+
const data = generateData(10, 20);
329+
330+
await createWidget('dxDataGrid', {
331+
dataSource: data,
332+
width: 400,
333+
height: 400,
334+
columns,
335+
columnFixing: {
336+
enabled: true,
337+
},
338+
columnMinWidth: 100,
339+
scrolling: {
340+
columnRenderingMode: 'virtual',
341+
},
342+
summary: {
343+
groupItems: [{
344+
column: columns[2].dataField,
345+
summaryType: 'count',
346+
alignByColumn: true,
347+
}],
348+
},
349+
});
350+
});

‎packages/devextreme/js/__internal/grids/grid_core/column_fixing/m_column_fixing.ts‎

Lines changed: 24 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -114,19 +114,19 @@ const baseFixedColumns = <T extends ModuleType<ColumnsView>>(Base: T) => class B
114114
}
115115
}
116116

117-
private _partialUpdateFixedTable(fixedColumns) {
117+
private _partialUpdateFixedTable(fixedColumns, rows) {
118118
const fixedTableElement = this._fixedTableElement;
119119
const $rows = this._getRowElementsCore(fixedTableElement);
120120
const $colgroup = fixedTableElement.children('colgroup');
121121

122122
$colgroup.replaceWith(this._createColGroup(fixedColumns));
123123

124-
for (let i = 0; i < $rows.length; i++) {
125-
this._partialUpdateFixedRow($($rows[i]), fixedColumns);
124+
for (let i = 0; i < rows.length; i++) {
125+
this._partialUpdateFixedRow($($rows[i]), fixedColumns, rows[i]);
126126
}
127127
}
128128

129-
private _partialUpdateFixedRow($row, fixedColumns) {
129+
private _partialUpdateFixedRow($row, fixedColumns, row) {
130130
const cellElements = $row.get(0).childNodes;
131131
const transparentColumnIndex = getTransparentColumnIndex(fixedColumns);
132132
const transparentColumn = fixedColumns[transparentColumnIndex];
@@ -144,11 +144,23 @@ const baseFixedColumns = <T extends ModuleType<ColumnsView>>(Base: T) => class B
144144
if ($row.hasClass(GROUP_ROW_CLASS)) {
145145
// @ts-expect-error RowsView's method
146146
groupCellOptions = this._getGroupCellOptions({
147-
row: $row.data('options'),
147+
row,
148148
columns: this._columnsController.getVisibleColumns(),
149149
});
150150

151-
colspan = groupCellOptions.colspan - Math.max(0, cellElements.length - (groupCellOptions.columnIndex + 2));
151+
const hasSummary = row.summaryCells.length > 0;
152+
if (hasSummary) {
153+
// @ts-expect-error RowsView's method
154+
const alignByColumnCellCount = this._getAlignByColumnCellCount(groupCellOptions.colspan, {
155+
columns: this._columnsController.getVisibleColumns(),
156+
row,
157+
isFixed: true,
158+
});
159+
160+
colspan = groupCellOptions.colspan - alignByColumnCellCount;
161+
} else {
162+
colspan = groupCellOptions.colspan - Math.max(0, cellElements.length - (groupCellOptions.columnIndex + 2));
163+
}
152164
}
153165

154166
for (let j = 0; j < cellElements.length; j++) {
@@ -180,7 +192,7 @@ const baseFixedColumns = <T extends ModuleType<ColumnsView>>(Base: T) => class B
180192
this._isFixedTableRendering = true;
181193

182194
if (needPartialUpdate && this.option('scrolling.legacyMode') !== true) {
183-
this._partialUpdateFixedTable(fixedColumns);
195+
this._partialUpdateFixedTable(fixedColumns, options?.change?.items);
184196
this._isFixedTableRendering = false;
185197
} else {
186198
const columnIndices = change?.columnIndices;
@@ -301,14 +313,14 @@ const baseFixedColumns = <T extends ModuleType<ColumnsView>>(Base: T) => class B
301313
if (options.row.summaryCells && options.row.summaryCells.length) {
302314
const columns = this._columnsController.getVisibleColumns();
303315
// @ts-expect-error DataGrid's method
304-
const alignByFixedColumnCellCount = this._getAlignByColumnCellCount
305-
// @ts-expect-error DataGrid's method
306-
? this._getAlignByColumnCellCount(column.colspan, {
316+
const alignByFixedColumnCellCount = this._getAlignByColumnCellCount?.(
317+
column.colspan,
318+
{
307319
columns,
308320
row: options.row,
309321
isFixed: true,
310-
})
311-
: 0;
322+
},
323+
) ?? 0;
312324

313325
if (alignByFixedColumnCellCount > 0) {
314326
const transparentColumnIndex = getTransparentColumnIndex(this._columnsController.getFixedColumns());

0 commit comments

Comments
 (0)