@adaptabletools/adaptable-cjs 20.0.4-canary.3 → 20.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adaptabletools/adaptable-cjs",
3
- "version": "20.0.4-canary.3",
3
+ "version": "20.0.4",
4
4
  "description": "Powerful data-agnostic HTML5 AG Grid extension which provides advanced, cutting-edge functionality to meet all DataGrid requirements",
5
5
  "keywords": [
6
6
  "web-components",
@@ -12,14 +12,7 @@ export type TableAggregationColumns = {
12
12
  /**
13
13
  * Defines an Aggregated Column in a Pivot Layout
14
14
  */
15
- export type PivotAggregationColumns = {
16
- ColumnId: string;
17
- AggFunc: AggregationColumnValue;
18
- TotalColumn?: boolean | 'before' | 'after' | {
19
- PivotColumnId: string;
20
- ShowTotal?: boolean | 'before' | 'after';
21
- }[];
22
- }[];
15
+ export type PivotAggregationColumns = TableAggregationColumns;
23
16
  export declare const WEIGHTED_AVERAGE_AGG_FN_NAME = "weightedAvg";
24
17
  /**
25
18
  * Defines a Weighted Average Agg
@@ -148,18 +148,6 @@ export interface PivotLayout extends LayoutBase {
148
148
  * Row Grouped Columns Columns - must NOT be provided
149
149
  */
150
150
  RowGroupedColumns?: never;
151
- /**
152
- * Display Grand Total Row at the top or bottom of the Pivot Table
153
- */
154
- GrandTotalRow?: 'top' | 'bottom' | boolean;
155
- /**
156
- * Display automatically calculated Totals of all Pivot Columns, in the position specified
157
- */
158
- GrandTotalColumn?: 'before' | 'after' | boolean;
159
- /**
160
- * Display automatically calculated Totals within EACH Pivot Column Group, in the position specified
161
- */
162
- PivotGroupTotalColumn?: 'before' | 'after' | boolean;
163
151
  }
164
152
  /**
165
153
  * Manages how (and which) Row Group values are stored
@@ -209,16 +209,12 @@ const pivotLayoutToPivotLayoutModel = (pivotLayout) => {
209
209
  ColumnPinning: pivotLayout.ColumnPinning,
210
210
  PivotColumns: pivotLayout.PivotColumns,
211
211
  PivotExpandLevel: pivotLayout.PivotExpandLevel,
212
- PivotAggregationColumns: (pivotLayout.PivotAggregationColumns || []).map(({ ColumnId, AggFunc, TotalColumn }) => {
212
+ PivotAggregationColumns: (pivotLayout.PivotAggregationColumns || []).map(({ ColumnId, AggFunc }) => {
213
213
  return {
214
214
  ColumnId,
215
215
  AggFunc: toAggFunc(AggFunc),
216
- TotalColumn,
217
216
  };
218
217
  }),
219
- GrandTotalRow: pivotLayout.GrandTotalRow,
220
- GrandTotalColumn: pivotLayout.GrandTotalColumn,
221
- PivotGroupTotalColumn: pivotLayout.PivotGroupTotalColumn,
222
218
  RowGroupValues: pivotLayout.RowGroupValues
223
219
  ? pivotLayout.RowGroupValues.RowGroupDefaultBehavior === 'always-collapsed' ||
224
220
  pivotLayout.RowGroupValues.RowGroupDefaultBehavior === 'always-expanded'
@@ -344,29 +340,10 @@ const pivotLayoutModelToPivotLayout = (layoutModel, defaults) => {
344
340
  else {
345
341
  delete pivotLayout.RowGroupValues;
346
342
  }
347
- if (layoutModel.GrandTotalRow) {
348
- pivotLayout.GrandTotalRow = layoutModel.GrandTotalRow;
349
- }
350
- else {
351
- delete pivotLayout.GrandTotalRow;
352
- }
353
- if (layoutModel.GrandTotalColumn) {
354
- pivotLayout.GrandTotalColumn = layoutModel.GrandTotalColumn;
355
- }
356
- else {
357
- delete pivotLayout.GrandTotalColumn;
358
- }
359
- if (layoutModel.PivotGroupTotalColumn) {
360
- pivotLayout.PivotGroupTotalColumn = layoutModel.PivotGroupTotalColumn;
361
- }
362
- else {
363
- delete pivotLayout.PivotGroupTotalColumn;
364
- }
365
343
  if (layoutModel.PivotAggregationColumns) {
366
- pivotLayout.PivotAggregationColumns = (layoutModel.PivotAggregationColumns || []).map(({ ColumnId, AggFunc, TotalColumn }) => ({
344
+ pivotLayout.PivotAggregationColumns = (layoutModel.PivotAggregationColumns || []).map(({ ColumnId, AggFunc }) => ({
367
345
  ColumnId,
368
346
  AggFunc: toAggregationColumnValue(AggFunc),
369
- TotalColumn,
370
347
  }));
371
348
  }
372
349
  else {
@@ -43,5 +43,5 @@ export declare class ColumnFilterInternalApi extends ApiBase {
43
43
  areColumnFiltersDifferent(oldFilters: ColumnFilter[], newFilters: ColumnFilter[]): boolean;
44
44
  getPredicateDefShortcuts(predicateDef: AdaptablePredicateDef): string[];
45
45
  showQuickFilterDropdown(columnId: string): boolean;
46
- openColumnFilterPopup(columnId: string): void;
46
+ openColumnFilterPopup(columnId: string, popupProps?: any): void;
47
47
  }
@@ -191,7 +191,7 @@ class ColumnFilterInternalApi extends ApiBase_1.ApiBase {
191
191
  }
192
192
  return true;
193
193
  }
194
- openColumnFilterPopup(columnId) {
194
+ openColumnFilterPopup(columnId, popupProps) {
195
195
  this.getAdaptableInternalApi().showPopupWindow({
196
196
  id: windowFactory_1.COLUMN_FILTER_WINDOW,
197
197
  title: ModuleConstants.ColumnFilterFriendlyName,
@@ -203,6 +203,7 @@ class ColumnFilterInternalApi extends ApiBase_1.ApiBase {
203
203
  width: 380,
204
204
  height: 450,
205
205
  },
206
+ ...popupProps,
206
207
  },
207
208
  });
208
209
  }
@@ -64,6 +64,12 @@ class CalculatedColumnModule extends AdaptableModuleBase_1.AdaptableModuleBase {
64
64
  return (this.api.namedQueryApi.internalApi.getReferencedNamedQueryNames(this.api.expressionApi.getAdaptableQueryExpression(calculatedColumn.Query)) ?? []);
65
65
  }
66
66
  createColumnMenuItems(column) {
67
+ if (!column) {
68
+ return;
69
+ }
70
+ if (!this.isModuleAvailable()) {
71
+ return;
72
+ }
67
73
  if (this.isModuleEditable() && column.isCalculatedColumn) {
68
74
  const popupParam = {
69
75
  column: column,
@@ -76,6 +82,9 @@ class CalculatedColumnModule extends AdaptableModuleBase_1.AdaptableModuleBase {
76
82
  }
77
83
  }
78
84
  createContextMenuItems(menuContext) {
85
+ if (!menuContext.adaptableColumn) {
86
+ return;
87
+ }
79
88
  if (!this.isModuleAvailable()) {
80
89
  return;
81
90
  }
@@ -38,6 +38,6 @@ const AdaptableFloatingFilter = (props) => {
38
38
  ]);
39
39
  props.onChange?.();
40
40
  }
41
- }, onClear: onClear, columnId: props.Column.columnId, predicate: qlPredicate, predicateDefs: qlPredicateDefs, disabled: columnFilter?.IsSuspended, onPredicateChange: onPredicateChange }));
41
+ }, onClear: onClear, columnId: props.Column.columnId, predicate: qlPredicate, predicateDefs: qlPredicateDefs, disabled: columnFilter?.IsSuspended, onPredicateChange: onPredicateChange, onChange: props.onChange }));
42
42
  };
43
43
  exports.AdaptableFloatingFilter = AdaptableFloatingFilter;
@@ -16,6 +16,7 @@ const ColumnFilterWindow = (props) => {
16
16
  React.useEffect(() => {
17
17
  setColumnId(initialColumnId);
18
18
  }, [props.popupProps.value]);
19
+ const onChange = props.popupProps.onChange;
19
20
  return (React.createElement(rebass_1.Flex, { flex: 1, minHeight: 0, height: "100%", flexDirection: "column", p: 2, className: "ab-ColumnFilterWindow" },
20
21
  React.createElement(rebass_1.Box, { mb: 2 },
21
22
  React.createElement(FormLayout_1.default, null,
@@ -32,6 +33,6 @@ const ColumnFilterWindow = (props) => {
32
33
  }
33
34
  return label;
34
35
  }, onChange: (column) => setColumnId(column), filterColumn: (column) => column.queryable, isMulti: false, value: columnId })))),
35
- React.createElement(AdaptableColumnFilter_1.AdaptableColumnFilter, { columnId: columnId })));
36
+ React.createElement(AdaptableColumnFilter_1.AdaptableColumnFilter, { columnId: columnId, onChange: onChange })));
36
37
  };
37
38
  exports.ColumnFilterWindow = ColumnFilterWindow;
@@ -8,5 +8,6 @@ export interface FloatingFilterProps {
8
8
  onPredicateChange: (predicate: QlPredicate) => void;
9
9
  onKeydown?: (event: React.KeyboardEventHandler<HTMLDivElement>) => void;
10
10
  onClear?: () => void;
11
+ onChange?: () => void;
11
12
  }
12
13
  export declare const FloatingFilter: React.FunctionComponent<FloatingFilterProps>;
@@ -81,7 +81,9 @@ const FloatingFilter = (props) => {
81
81
  });
82
82
  } }))),
83
83
  isInlineEditable && (React.createElement(SimpleButton_1.default, { px: 0, onClick: () => {
84
- adaptable.api.filterApi.columnFilterApi.internalApi.openColumnFilterPopup(props.columnId);
84
+ adaptable.api.filterApi.columnFilterApi.internalApi.openColumnFilterPopup(props.columnId, {
85
+ onChange: props.onChange,
86
+ });
85
87
  }, "data-name": "expand-filter", icon: "expand", variant: "text" })),
86
88
  (isMultiple ||
87
89
  !(0, utils_1.isPredicateEmpty)(props.predicate.args[0], singleFilterPredicateDef)) && (React.createElement(SimpleButton_1.default, { "data-name": "clear-filter", p: 0, variant: "text", onClick: handleClear, icon: "close" }))));
@@ -28,7 +28,7 @@ const ColumnValuesSelect = (props) => {
28
28
  }
29
29
  return true;
30
30
  });
31
- const component = (React.createElement(Select_1.Select, { isMulti: true, showHeaderSelectionCheckbox: true, searchable: true, closeMenuOnSelect: false, size: "small", menuStyle: {
31
+ const component = (React.createElement(Select_1.Select, { isMulti: true, showHeaderSelectionCheckbox: true, searchable: true, closeMenuOnSelect: false, menuStyle: {
32
32
  minWidth: `var(--ab-cmp-select-column-menu-${column.columnId}__min-width, var(--ab-cmp-select-column-menu__min-width, 260px))`,
33
33
  }, ...props.selectProps, options: options, value: value, isLoading: props.isLoading, onChange: props.onChange }));
34
34
  return (React.createElement("div", { className: (0, join_1.default)(baseClassName, props.isLoading && `${baseClassName}--loading`, !value.length && `${baseClassName}--empty`), onKeyDownCapture: (e) => {
package/src/env.js CHANGED
@@ -2,6 +2,6 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.default = {
4
4
  NEXT_PUBLIC_INFINITE_TABLE_LICENSE_KEY: "StartDate=2021-06-29|EndDate=2030-01-01|Owner=Adaptable|Type=distribution|TS=1624971462479|C=137829811,1004007071,2756196225,1839832928,3994409405,636616862" || '',
5
- PUBLISH_TIMESTAMP: 1744658469734 || Date.now(),
6
- VERSION: "20.0.4-canary.3" || '--current-version--',
5
+ PUBLISH_TIMESTAMP: 1744726373908 || Date.now(),
6
+ VERSION: "20.0.4" || '--current-version--',
7
7
  };
@@ -62,17 +62,26 @@ export type ColumnAggregationModel = {
62
62
  aggFunc: string | true;
63
63
  weightedColumnId?: string;
64
64
  };
65
- export type AggregationColumnsModelItem = {
65
+ export type AggregationColumnsModel = {
66
66
  ColumnId: string;
67
67
  AggFunc: ColumnAggregationModel;
68
- };
69
- export type AggregationColumnsModel = AggregationColumnsModelItem[];
70
- export type PivotAggregationColumnsModel = (AggregationColumnsModelItem & {
71
- TotalColumn?: boolean | 'before' | 'after' | {
72
- PivotColumnId: string;
73
- ShowTotal?: boolean | 'before' | 'after';
74
- }[];
75
- })[];
68
+ }[];
69
+ type RowSummaryPosition = 'Top' | 'Bottom';
70
+ export interface RowSummaryModel {
71
+ /**
72
+ * Where Row Summary appears - 'Top' or 'Bottom'
73
+ */
74
+ Position?: RowSummaryPosition;
75
+ /**
76
+ * Map of Columns with Summary Expressions
77
+ */
78
+ ColumnsMap: Record<string, string>;
79
+ /**
80
+ * Evaluates only currently filtered rows in the summary
81
+ * @defaultValue true
82
+ */
83
+ IncludeOnlyFilteredRows?: boolean;
84
+ }
76
85
  export interface TableLayoutModel extends BaseLayoutModel {
77
86
  TableColumns: string[];
78
87
  /**
@@ -87,7 +96,6 @@ export interface TableLayoutModel extends BaseLayoutModel {
87
96
  * @defaultValue 'single'
88
97
  */
89
98
  RowGroupDisplayType?: 'single' | 'multi';
90
- PivotAggregationColumns?: never;
91
99
  PivotColumns?: never;
92
100
  PivotGroupedColumns?: never;
93
101
  PivotExpandLevel?: never;
@@ -102,24 +110,13 @@ export interface PivotLayoutModel extends BaseLayoutModel {
102
110
  /**
103
111
  * Columns showing aggregated values in Group Rows; 1st value in record is Column name, 2nd is either aggfunc (e.g. sum, avg etc.) or 'true' (to use default aggfunc)
104
112
  */
105
- PivotAggregationColumns?: PivotAggregationColumnsModel;
113
+ PivotAggregationColumns?: AggregationColumnsModel;
106
114
  TableAggregationColumns?: never;
107
115
  /**
108
116
  * Columns which are row-grouped when the Layout is applied
109
117
  */
110
118
  PivotGroupedColumns?: string[];
111
119
  RowGroupedColumns?: never;
112
- /**
113
- * Display Grand Total Row at the top or bottom of the Pivot Table
114
- */
115
- GrandTotalRow?: 'top' | 'bottom' | boolean;
116
- /**
117
- * Display Total of all Pivot Columns before or after the Pivot Columns
118
- */
119
- GrandTotalColumn?: 'before' | 'after' | boolean;
120
- /**
121
- * Display automatically calculated Totals within EACH Pivot Column Group, in the position specified
122
- */
123
- PivotGroupTotalColumn?: 'before' | 'after' | boolean;
124
120
  }
125
121
  export type LayoutModel = TableLayoutModel | PivotLayoutModel;
122
+ export {};
@@ -69,16 +69,7 @@ export declare class LayoutManager<DATA_TYPE = any> extends LMEmitter {
69
69
  private computeColumnOrderAndVisibility;
70
70
  autoSizeColumns(columnIds?: string[]): false | string[];
71
71
  private applyPivotLayout;
72
- applyPivotTotals(layout: PivotLayoutModel): void;
73
72
  applyPivotExpandLevel(layout: PivotLayoutModel): void;
74
73
  private withSuppressColumnAnimation;
75
- private setupPivotTotals;
76
- private isPivotRowTotalColDef;
77
- private patchGrandTotalColumn;
78
- private isPivotGroupTotalColumn;
79
- private patchPivotGroupTotalColumn;
80
- private patchPivotTotalColumn;
81
- private destructurePivotColumnId;
82
- private getPivotTotalColumnConfig;
83
74
  }
84
75
  export {};
@@ -120,12 +120,8 @@ class LayoutManager extends LMEmitter_1.LMEmitter {
120
120
  }).bind(this);
121
121
  }
122
122
  this.setOptions(options);
123
- // this ensures the grand total columns are positioned correctly (before/after) even when changed at runtime
124
- // see https://www.ag-grid.com/react-data-grid/pivoting-column-groups/#changing-data-filters-and-configurations
125
- this.gridApi.setGridOption('enableStrictPivotColumnOrder', true);
126
123
  this.setupEvents();
127
124
  this.indexColumns();
128
- this.setupPivotTotals();
129
125
  globalThis.layoutManager = this;
130
126
  }
131
127
  destroy() {
@@ -259,18 +255,6 @@ class LayoutManager extends LMEmitter_1.LMEmitter {
259
255
  PivotAggregationColumns: layout.TableAggregationColumns,
260
256
  PivotExpandLevel: prevLayout?.PivotExpandLevel ?? -1,
261
257
  };
262
- const grandTotalRow = this.gridApi.getGridOption('grandTotalRow');
263
- if (grandTotalRow) {
264
- pivotLayout.GrandTotalRow = grandTotalRow;
265
- }
266
- const grandTotalColumn = this.gridApi.getGridOption('pivotRowTotals');
267
- if (grandTotalColumn) {
268
- pivotLayout.GrandTotalColumn = grandTotalColumn;
269
- }
270
- const pivotGroupTotalColumn = this.gridApi.getGridOption('pivotColumnGroupTotals');
271
- if (pivotGroupTotalColumn) {
272
- pivotLayout.PivotGroupTotalColumn = pivotGroupTotalColumn;
273
- }
274
258
  return (0, simplifyLayoutModel_1.simplifyPivotLayoutModel)(pivotLayout);
275
259
  }
276
260
  getTableLayoutModelFromGrid() {
@@ -291,7 +275,7 @@ class LayoutManager extends LMEmitter_1.LMEmitter {
291
275
  let ColumnPinning = {};
292
276
  const gridState = this.gridApi.getState();
293
277
  const prevLayout = this.currentLayout;
294
- const prevAggColumns = prevLayout?.TableAggregationColumns ?? prevLayout?.PivotAggregationColumns;
278
+ const prevAggColumns = prevLayout?.TableAggregationColumns;
295
279
  const prevAggColumnsMap = prevAggColumns?.reduce((acc, agg) => {
296
280
  acc[agg.ColumnId] = agg;
297
281
  return acc;
@@ -1002,7 +986,6 @@ class LayoutManager extends LMEmitter_1.LMEmitter {
1002
986
  return columnIds;
1003
987
  }
1004
988
  applyPivotLayout(layout, options) {
1005
- this.applyPivotTotals(layout);
1006
989
  const columnState = this.computeColumnStateForPivotLayout(layout);
1007
990
  // by simply calling this.gridApi.applyColumnState(columnState)
1008
991
  // the order of aggregations is not preserved/guaranteed by ag-grid
@@ -1030,50 +1013,6 @@ class LayoutManager extends LMEmitter_1.LMEmitter {
1030
1013
  this.applyRowGroupValues(layout.RowGroupValues);
1031
1014
  }
1032
1015
  }
1033
- applyPivotTotals(layout) {
1034
- /**
1035
- * GrandTotalRow
1036
- */
1037
- if (layout.GrandTotalRow) {
1038
- const grandTotalRow = layout.GrandTotalRow === true || layout.GrandTotalRow === 'top'
1039
- ? 'top'
1040
- : layout.GrandTotalRow === 'bottom'
1041
- ? 'bottom'
1042
- : null;
1043
- this.gridApi.setGridOption('grandTotalRow', grandTotalRow);
1044
- }
1045
- else {
1046
- this.gridApi.setGridOption('grandTotalRow', null);
1047
- }
1048
- /**
1049
- * GrandTotalColumn
1050
- */
1051
- if (layout.GrandTotalColumn) {
1052
- const grandTotalColumn = layout.GrandTotalColumn === true || layout.GrandTotalColumn === 'before'
1053
- ? 'before'
1054
- : layout.GrandTotalColumn === 'after'
1055
- ? 'after'
1056
- : null;
1057
- this.gridApi.setGridOption('pivotRowTotals', grandTotalColumn);
1058
- }
1059
- else {
1060
- this.gridApi.setGridOption('pivotRowTotals', null);
1061
- }
1062
- /**
1063
- * PivotGroupTotalColumn
1064
- */
1065
- if (layout.PivotGroupTotalColumn) {
1066
- const pivotGroupTotalColumn = layout.PivotGroupTotalColumn === true || layout.PivotGroupTotalColumn === 'before'
1067
- ? 'before'
1068
- : layout.PivotGroupTotalColumn === 'after'
1069
- ? 'after'
1070
- : null;
1071
- this.gridApi.setGridOption('pivotColumnGroupTotals', pivotGroupTotalColumn);
1072
- }
1073
- else {
1074
- this.gridApi.setGridOption('pivotColumnGroupTotals', null);
1075
- }
1076
- }
1077
1016
  applyPivotExpandLevel(layout) {
1078
1017
  const PivotExpandLevel = layout.PivotExpandLevel ?? -1;
1079
1018
  const allDisplayedColumnGroups = this.gridApi.getAllDisplayedColumnGroups();
@@ -1109,166 +1048,5 @@ class LayoutManager extends LMEmitter_1.LMEmitter {
1109
1048
  }
1110
1049
  return res;
1111
1050
  }
1112
- setupPivotTotals() {
1113
- const _original_processPivotResultColDef = this.gridApi.getGridOption('processPivotResultColDef');
1114
- this.gridApi.setGridOption('processPivotResultColDef', (resulColDef) => {
1115
- _original_processPivotResultColDef?.(resulColDef);
1116
- if (!(0, isPivotLayoutModel_1.isPivotLayoutModel)(this.currentLayout)) {
1117
- return;
1118
- }
1119
- this.patchGrandTotalColumn(resulColDef);
1120
- this.patchPivotGroupTotalColumn(resulColDef);
1121
- });
1122
- const _original_processPivotResultColGroupDef = this.gridApi.getGridOption('processPivotResultColGroupDef');
1123
- this.gridApi.setGridOption('processPivotResultColGroupDef', (colGroupDef) => {
1124
- _original_processPivotResultColGroupDef?.(colGroupDef);
1125
- if (!(0, isPivotLayoutModel_1.isPivotLayoutModel)(this.currentLayout)) {
1126
- return;
1127
- }
1128
- this.patchPivotTotalColumn(colGroupDef);
1129
- });
1130
- }
1131
- isPivotRowTotalColDef(colDef) {
1132
- return colDef.colId?.startsWith('PivotRowTotal_');
1133
- }
1134
- patchGrandTotalColumn(resultColDef) {
1135
- if (!(0, isPivotLayoutModel_1.isPivotLayoutModel)(this.currentLayout) || !this.currentLayout.GrandTotalColumn) {
1136
- return;
1137
- }
1138
- if (this.isPivotRowTotalColDef(resultColDef)) {
1139
- resultColDef.headerName = `Grand Total ${resultColDef.headerName}`;
1140
- }
1141
- }
1142
- isPivotGroupTotalColumn(colDef) {
1143
- // pivot group total are spanning cross all aggregations
1144
- // therefore the last part of the colId is empty (hence the "dangling" underscore)
1145
- return colDef.colId?.startsWith('pivot_') && colDef.colId?.endsWith('_');
1146
- }
1147
- patchPivotGroupTotalColumn(resultColDef) {
1148
- if (!(0, isPivotLayoutModel_1.isPivotLayoutModel)(this.currentLayout) || !this.currentLayout.PivotGroupTotalColumn) {
1149
- return;
1150
- }
1151
- if (this.isPivotGroupTotalColumn(resultColDef)) {
1152
- // resultColDef
1153
- const colInfo = this.destructurePivotColumnId(resultColDef.colId);
1154
- if (colInfo !== '!unknown!') {
1155
- const currentPivotKey = colInfo.pivotKeys[colInfo.pivotKeys.length - 1];
1156
- resultColDef.headerName = `${currentPivotKey} Total`;
1157
- }
1158
- }
1159
- }
1160
- patchPivotTotalColumn(colGroupDef) {
1161
- const hasPivotTotalCols = (pivotLayout) => {
1162
- return pivotLayout.PivotAggregationColumns?.some((aggCol) => !!aggCol.TotalColumn);
1163
- };
1164
- const isPivotTotalColDef = (colDef) => {
1165
- return !!colDef.pivotTotalColumnIds?.length;
1166
- };
1167
- if (!(0, isPivotLayoutModel_1.isPivotLayoutModel)(this.currentLayout) || !hasPivotTotalCols(this.currentLayout)) {
1168
- return;
1169
- }
1170
- const pivotRowTotalColDefsBefore = [];
1171
- const pivotRowTotalColDefsAfter = [];
1172
- const pivotTotalColDefsBefore = [];
1173
- const pivotTotalColDefsAfter = [];
1174
- const normalColDefs = [];
1175
- colGroupDef.children.forEach((colDef) => {
1176
- if (this.isPivotRowTotalColDef(colDef)) {
1177
- if (this.gridApi.getGridOption('pivotRowTotals') === 'after') {
1178
- pivotRowTotalColDefsAfter.push(colDef);
1179
- }
1180
- else {
1181
- pivotRowTotalColDefsBefore.push(colDef);
1182
- }
1183
- return;
1184
- }
1185
- if (isPivotTotalColDef(colDef)) {
1186
- if (!colDef.colId.startsWith('pivot_')) {
1187
- this.warn(`Pivot total column ${colDef.colId} is not prefixed with 'pivot_', skipping...`);
1188
- return;
1189
- }
1190
- // we do this for all total cols, but we will hide the ones that are not visible
1191
- colDef.columnGroupShow = undefined;
1192
- colDef.headerName = `Total ${colDef.headerName}`;
1193
- const totalColConfig = this.getPivotTotalColumnConfig(colDef, this.currentLayout);
1194
- if (!totalColConfig.visible) {
1195
- colDef.hide = true;
1196
- }
1197
- else {
1198
- if (totalColConfig.position === 'after') {
1199
- pivotTotalColDefsAfter.push(colDef);
1200
- }
1201
- else {
1202
- pivotTotalColDefsBefore.push(colDef);
1203
- }
1204
- }
1205
- }
1206
- else {
1207
- normalColDefs.push(colDef);
1208
- }
1209
- });
1210
- colGroupDef.children = [
1211
- ...pivotRowTotalColDefsBefore,
1212
- ...pivotTotalColDefsBefore,
1213
- ...normalColDefs,
1214
- ...pivotTotalColDefsAfter,
1215
- ...pivotRowTotalColDefsAfter,
1216
- ];
1217
- }
1218
- destructurePivotColumnId(colId = '') {
1219
- // Split by underscore to get 4 parts
1220
- const parts = colId.split('_');
1221
- if (parts.length !== 4) {
1222
- this.warn(`Unsupported format of pivot total column id: ${colId}`);
1223
- return '!unknown!';
1224
- }
1225
- // e.g.
1226
- // pivot_country-sport-year_United States-Basketball_gold
1227
- // pivotColumnIds: ['country', 'sport', 'year']
1228
- // pivotKeys: ['United States', 'Basketball']
1229
- // aggregationColumnId: 'gold'
1230
- const [_pivotPrefix, pivotColsTxt, pivotKeysTxt, aggregationColumnId] = parts;
1231
- const pivotColumnIds = pivotColsTxt.split('-');
1232
- const pivotKeys = pivotKeysTxt.split('-');
1233
- const pivotColumnId = pivotColumnIds[pivotKeys.length - 1];
1234
- return {
1235
- pivotColumnIds,
1236
- pivotKeys,
1237
- pivotColumnId,
1238
- aggregationColumnId,
1239
- };
1240
- }
1241
- getPivotTotalColumnConfig(colDef, currentPivotLayout) {
1242
- const defaultHiddenConfig = {
1243
- visible: false,
1244
- };
1245
- const colIdInfo = this.destructurePivotColumnId(colDef.colId);
1246
- if (colIdInfo === '!unknown!') {
1247
- return defaultHiddenConfig;
1248
- }
1249
- const { pivotColumnId, aggregationColumnId } = colIdInfo;
1250
- const layoutAggCol = currentPivotLayout.PivotAggregationColumns?.find((col) => col.ColumnId === aggregationColumnId);
1251
- if (!layoutAggCol) {
1252
- this.warn(`Pivot Totals: could NOT find aggregation(value) column with id ${aggregationColumnId}`);
1253
- return defaultHiddenConfig;
1254
- }
1255
- const layoutPivotTotalColumn = layoutAggCol.TotalColumn;
1256
- if (!layoutPivotTotalColumn) {
1257
- return defaultHiddenConfig;
1258
- }
1259
- if (Array.isArray(layoutPivotTotalColumn)) {
1260
- const pivotSpecificConfig = layoutPivotTotalColumn.find((config) => config.PivotColumnId === pivotColumnId);
1261
- return {
1262
- visible: pivotSpecificConfig && pivotSpecificConfig.ShowTotal !== false,
1263
- position: pivotSpecificConfig?.ShowTotal === 'after' ? 'after' : 'before',
1264
- };
1265
- }
1266
- else {
1267
- return {
1268
- visible: !!layoutPivotTotalColumn,
1269
- position: layoutPivotTotalColumn === 'after' ? 'after' : 'before',
1270
- };
1271
- }
1272
- }
1273
1051
  }
1274
1052
  exports.LayoutManager = LayoutManager;
@@ -144,9 +144,6 @@ function normalizePivotLayoutModel(layout) {
144
144
  // make it an own property
145
145
  layout.SuppressAggFuncInHeader = undefined;
146
146
  }
147
- if (!layout.GrandTotalRow) {
148
- layout.GrandTotalRow = false;
149
- }
150
147
  return layout;
151
148
  }
152
149
  exports.normalizePivotLayoutModel = normalizePivotLayoutModel;
@@ -18,7 +18,7 @@ function simplifyTableLayoutModel(layout) {
18
18
  delete layout.RowGroupedColumns;
19
19
  }
20
20
  if (!layout.RowGroupedColumns && layout.RowGroupValues) {
21
- delete layout.RowGroupValues;
21
+ // delete layout.RowGroupValues;
22
22
  }
23
23
  if (layout.SuppressAggFuncInHeader === undefined) {
24
24
  delete layout.SuppressAggFuncInHeader;