From 6769ff3e148a15eaedd35abc48a0b4e911953d9a Mon Sep 17 00:00:00 2001 From: gzh2003 Date: Thu, 26 Mar 2026 12:37:32 -0400 Subject: [PATCH 1/2] detect model switch in progress --- packages/iris-grid/src/IrisGrid.tsx | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/packages/iris-grid/src/IrisGrid.tsx b/packages/iris-grid/src/IrisGrid.tsx index 235da947de..1756bdc0ed 100644 --- a/packages/iris-grid/src/IrisGrid.tsx +++ b/packages/iris-grid/src/IrisGrid.tsx @@ -1382,6 +1382,7 @@ class IrisGrid extends Component { getModelTotalsConfig = memoize( ( columns: readonly DhType.Column[], + originalColumns: readonly DhType.Column[], config: UIRollupConfig | undefined, aggregationSettings: AggregationSettings ): UITotalsTableConfig | null => { @@ -1390,6 +1391,18 @@ class IrisGrid extends Component { return null; } + // TODO: evaluate whether this should be moved to proxy model, since it should manage the model transition + // When a rollup is being removed the model `columns` still reflects the tree table's columns + // while the rollup config has already been cleared. Building a totals config with those stale + // column names would cause a server error. + if ( + config != null && + config.columns.length === 0 && + columns !== originalColumns + ) { + return null; + } + // Filter out aggregations without any columns actually selected const aggregations = aggregationSettings.aggregations.filter( agg => agg.selected.length > 0 || agg.invert @@ -5235,6 +5248,7 @@ class IrisGrid extends Component { )} totalsConfig={this.getModelTotalsConfig( model.columns, + model.originalColumns, rollupConfig, aggregationSettings )} From cf4bd5a2c13bafbcb7c9d28e9e57d97b4d6235ee Mon Sep 17 00:00:00 2001 From: gzh2003 Date: Thu, 26 Mar 2026 12:38:29 -0400 Subject: [PATCH 2/2] move to proxy --- packages/iris-grid/src/IrisGrid.tsx | 14 -------------- packages/iris-grid/src/IrisGridProxyModel.ts | 11 ++++++++++- 2 files changed, 10 insertions(+), 15 deletions(-) diff --git a/packages/iris-grid/src/IrisGrid.tsx b/packages/iris-grid/src/IrisGrid.tsx index 1756bdc0ed..235da947de 100644 --- a/packages/iris-grid/src/IrisGrid.tsx +++ b/packages/iris-grid/src/IrisGrid.tsx @@ -1382,7 +1382,6 @@ class IrisGrid extends Component { getModelTotalsConfig = memoize( ( columns: readonly DhType.Column[], - originalColumns: readonly DhType.Column[], config: UIRollupConfig | undefined, aggregationSettings: AggregationSettings ): UITotalsTableConfig | null => { @@ -1391,18 +1390,6 @@ class IrisGrid extends Component { return null; } - // TODO: evaluate whether this should be moved to proxy model, since it should manage the model transition - // When a rollup is being removed the model `columns` still reflects the tree table's columns - // while the rollup config has already been cleared. Building a totals config with those stale - // column names would cause a server error. - if ( - config != null && - config.columns.length === 0 && - columns !== originalColumns - ) { - return null; - } - // Filter out aggregations without any columns actually selected const aggregations = aggregationSettings.aggregations.filter( agg => agg.selected.length > 0 || agg.invert @@ -5248,7 +5235,6 @@ class IrisGrid extends Component { )} totalsConfig={this.getModelTotalsConfig( model.columns, - model.originalColumns, rollupConfig, aggregationSettings )} diff --git a/packages/iris-grid/src/IrisGridProxyModel.ts b/packages/iris-grid/src/IrisGridProxyModel.ts index b193bb339e..9d46c3e143 100644 --- a/packages/iris-grid/src/IrisGridProxyModel.ts +++ b/packages/iris-grid/src/IrisGridProxyModel.ts @@ -11,7 +11,7 @@ import IrisGridTableModel from './IrisGridTableModel'; import IrisGridPartitionedTableModel from './IrisGridPartitionedTableModel'; import IrisGridTreeTableModel from './IrisGridTreeTableModel'; import IrisGridModel from './IrisGridModel'; -import { type ColumnName } from './CommonTypes'; +import { type ColumnName, type UITotalsTableConfig } from './CommonTypes'; import { isIrisGridTableModelTemplate } from './IrisGridTableModelTemplate'; import { type PartitionConfig, @@ -431,6 +431,15 @@ class IrisGridProxyModel extends IrisGridModel implements PartitionedGridModel { this.setNextModel(modelPromise); } + set totalsConfig(totalsConfig: UITotalsTableConfig | null) { + if (this.modelPromise != null) { + // Model switch in progress. Don't forward, as the config may reference stale columns. + // COLUMNS_CHANGED will reapply the correct config after. + return; + } + this.model.totalsConfig = totalsConfig; + } + get isFilterRequired(): boolean { return this.originalModel.isFilterRequired; }