Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"changes": [
{
"comment": "fix: hide row series number in aggregation rows",
"type": "none",
"packageName": "@visactor/vtable"
}
],
"packageName": "@visactor/vtable",
"email": "biukam.w@gmail.com"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
// @ts-nocheck
import { ListTable, TYPES } from '../../src';
import { createDiv } from '../dom';

global.__VERSION__ = 'none';

describe('ListTable row series number with aggregation', () => {
const container = createDiv();
container.style.width = '600px';
container.style.height = '400px';

const table = new ListTable(container, {
records: [{ value: 1 }, { value: 2 }],
columns: [
{
field: 'value',
title: 'Value',
aggregation: {
aggregationType: TYPES.AggregationType.SUM
}
}
],
rowSeriesNumber: {
title: 'No.'
}
});

afterAll(() => {
table.release();
});

test('does not display a series number in the aggregation row', () => {
const aggregationRow = table.rowCount - 1;

expect(table.internalProps.layoutMap.isAggregation(0, aggregationRow)).toBe(true);
expect(table.getCellValue(0, aggregationRow)).toBe('');
expect(table.getCellOriginValue(0, aggregationRow)).toBe('');
});
});
6 changes: 6 additions & 0 deletions packages/vtable/src/ListTable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -579,6 +579,9 @@ export class ListTable extends BaseTable implements ListTableAPI {
const { title } = table.internalProps.layoutMap.getSeriesNumberHeader(col, row);
return title;
}
if (table.internalProps.layoutMap.isAggregation(col, row)) {
return '';
}
let value;
if ((this.internalProps as ListTableProtected).groupBy) {
const record = table.getCellRawRecord(col, row);
Expand Down Expand Up @@ -629,6 +632,9 @@ export class ListTable extends BaseTable implements ListTableAPI {
const { title } = table.internalProps.layoutMap.getSeriesNumberHeader(col, row);
return title;
}
if (table.internalProps.layoutMap.isAggregation(col, row)) {
return '';
}
const { format } = table.internalProps.layoutMap.getSeriesNumberBody(col, row);
return typeof format === 'function' ? format(col, row, this) : row - this.columnHeaderLevelCount;
} else if (table.internalProps.layoutMap.isHeader(col, row)) {
Expand Down
Loading