Skip to content

Commit 0d9c3cb

Browse files
author
李杨枚
committed
feat: add configuration to display aggregation result when data is empty
1 parent 9a81998 commit 0d9c3cb

File tree

4 files changed

+14
-2
lines changed

4 files changed

+14
-2
lines changed

docs/assets/option/en/table/listTable.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,10 @@ type CustomAggregation = {
133133
};
134134
```
135135

136+
## showAggregationWhenEmpty(boolean)
137+
138+
Display aggregation result when data is empty.
139+
136140
## groupBy(string|string[])
137141

138142
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.

docs/assets/option/zh/table/listTable.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,10 @@ type CustomAggregation = {
130130
};
131131
```
132132

133+
## showAggregationWhenEmpty(boolean)
134+
135+
数据为空时是否仍显示聚合结果。
136+
133137
## groupBy(string|string[])
134138

135139
开启分组展示功能,用于展示数据中分组字段的层级结构。值为分组字段名称,可以配置一个字段,也可以配置多个字段组成的数组。

packages/vtable/src/ListTable.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -618,7 +618,10 @@ export class ListTable extends BaseTable implements ListTableAPI {
618618

619619
const dataCount = table.internalProps.dataSource?.length ?? 0;
620620
layoutMap.recordsCount =
621-
dataCount + (dataCount > 0 ? layoutMap.hasAggregationOnTopCount + layoutMap.hasAggregationOnBottomCount : 0);
621+
dataCount +
622+
(dataCount > 0 || !!this.options.showAggregationWhenEmpty
623+
? layoutMap.hasAggregationOnTopCount + layoutMap.hasAggregationOnBottomCount
624+
: 0);
622625

623626
if (table.transpose) {
624627
table.rowCount = layoutMap.rowCount ?? 0;

packages/vtable/src/ts-types/table-engine.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -280,7 +280,8 @@ export interface ListTableConstructorOptions extends BaseTableConstructorOptions
280280
col: number;
281281
field: string;
282282
}) => Aggregation | CustomAggregation | (Aggregation | CustomAggregation)[] | null);
283-
283+
/** 数据为空时显示聚合结果 */
284+
showAggregationWhenEmpty?: boolean;
284285
enableTreeNodeMerge?: boolean;
285286
groupBy?: GroupByOption;
286287
groupTitleCustomLayout?: ICustomLayout;

0 commit comments

Comments
 (0)