mirror of
https://github.com/VisActor/VTable
synced 2024-11-22 01:52:03 +00:00
fix: when call updateColumns should update aggregation #2519
This commit is contained in:
parent
4f12853fc6
commit
872842ac65
@ -19,7 +19,12 @@ import type {
|
||||
import { HierarchyState } from './ts-types';
|
||||
import { SimpleHeaderLayoutMap } from './layout';
|
||||
import { isArray, isValid } from '@visactor/vutils';
|
||||
import { _setDataSource, _setRecords, generateAggregationForColumn } from './core/tableHelper';
|
||||
import {
|
||||
_setDataSource,
|
||||
_setRecords,
|
||||
checkHasAggregationOnColumnDefine,
|
||||
generateAggregationForColumn
|
||||
} from './core/tableHelper';
|
||||
import { BaseTable } from './core';
|
||||
import type { BaseTableAPI, ListTableProtected } from './ts-types/base-table';
|
||||
import { TABLE_EVENT_TYPE } from './core/TABLE_EVENT_TYPE';
|
||||
@ -224,6 +229,10 @@ export class ListTable extends BaseTable implements ListTableAPI {
|
||||
this.internalProps.headerHelper.setTableColumnsEditor();
|
||||
this._hasAutoImageColumn = undefined;
|
||||
this.refreshHeader();
|
||||
this.dataSource.updateColumns?.(this.internalProps.columns);
|
||||
if (this.records && checkHasAggregationOnColumnDefine(columns)) {
|
||||
this.dataSource.processRecords(this.dataSource.dataSourceObj?.records ?? this.dataSource.dataSourceObj);
|
||||
}
|
||||
this.internalProps.useOneRowHeightFillAll = false;
|
||||
this.scenegraph.clearCells();
|
||||
this.headerStyleCache = new Map();
|
||||
|
@ -7,6 +7,7 @@ import { Rect } from '../tools/Rect';
|
||||
import * as calc from '../tools/calc';
|
||||
import type {
|
||||
Aggregation,
|
||||
ColumnsDefine,
|
||||
CustomAggregation,
|
||||
FullExtendStyle,
|
||||
ListTableAPI,
|
||||
@ -472,3 +473,13 @@ export function generateAggregationForColumn(table: ListTable) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export function checkHasAggregationOnColumnDefine(colDefs: ColumnsDefine) {
|
||||
for (let i = 0; i < colDefs.length; i++) {
|
||||
const colDef = colDefs[i];
|
||||
if (colDef.aggregation) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
@ -275,8 +275,12 @@ export class DataSource extends EventTarget implements DataSourceAPI {
|
||||
this.registerAggregator(AggregationType.NONE, NoneAggregator);
|
||||
this.registerAggregator(AggregationType.CUSTOM, CustomAggregator);
|
||||
}
|
||||
updateColumns(columns: ColumnsDefine) {
|
||||
this.columns = columns;
|
||||
}
|
||||
_generateFieldAggragations() {
|
||||
const columnObjs = this.columns;
|
||||
this.fieldAggregators = [];
|
||||
for (let i = 0; i < columnObjs?.length; i++) {
|
||||
delete (columnObjs[i] as any).vtable_aggregator; //重置聚合器 如更新了过滤条件都需要重新计算
|
||||
const field = columnObjs[i].field;
|
||||
|
Loading…
Reference in New Issue
Block a user