Skip to content
Merged
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
4 changes: 4 additions & 0 deletions docs/assets/option/en/table/listTable.md
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,10 @@ type CustomAggregation = {
};
```

## showAggregationWhenEmpty(boolean)

Display aggregation result when data is empty.

## groupBy(string|string[])

Enable the group display function to display the hierarchical structure of the group fields in the data. The value is the group field name, which can be configured as one field or an array of multiple fields.
Expand Down
4 changes: 4 additions & 0 deletions docs/assets/option/zh/table/listTable.md
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,10 @@ type CustomAggregation = {
};
```

## showAggregationWhenEmpty(boolean)

数据为空时是否仍显示聚合结果。

## groupBy(string|string[])

开启分组展示功能,用于展示数据中分组字段的层级结构。值为分组字段名称,可以配置一个字段,也可以配置多个字段组成的数组。
Expand Down
5 changes: 4 additions & 1 deletion packages/vtable/src/ListTable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -618,7 +618,10 @@ export class ListTable extends BaseTable implements ListTableAPI {

const dataCount = table.internalProps.dataSource?.length ?? 0;
layoutMap.recordsCount =
dataCount + (dataCount > 0 ? layoutMap.hasAggregationOnTopCount + layoutMap.hasAggregationOnBottomCount : 0);
dataCount +
(dataCount > 0 || !!this.options.showAggregationWhenEmpty
? layoutMap.hasAggregationOnTopCount + layoutMap.hasAggregationOnBottomCount
: 0);

if (table.transpose) {
table.rowCount = layoutMap.rowCount ?? 0;
Expand Down
3 changes: 2 additions & 1 deletion packages/vtable/src/ts-types/table-engine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,8 @@ export interface ListTableConstructorOptions extends BaseTableConstructorOptions
col: number;
field: string;
}) => Aggregation | CustomAggregation | (Aggregation | CustomAggregation)[] | null);

/** 数据为空时显示聚合结果 */
showAggregationWhenEmpty?: boolean;
enableTreeNodeMerge?: boolean;
groupBy?: GroupByOption;
groupTitleCustomLayout?: ICustomLayout;
Expand Down
Loading