@adaptabletools/adaptable 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",
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
@@ -197,16 +197,12 @@ export const pivotLayoutToPivotLayoutModel = (pivotLayout) => {
197
197
  ColumnPinning: pivotLayout.ColumnPinning,
198
198
  PivotColumns: pivotLayout.PivotColumns,
199
199
  PivotExpandLevel: pivotLayout.PivotExpandLevel,
200
- PivotAggregationColumns: (pivotLayout.PivotAggregationColumns || []).map(({ ColumnId, AggFunc, TotalColumn }) => {
200
+ PivotAggregationColumns: (pivotLayout.PivotAggregationColumns || []).map(({ ColumnId, AggFunc }) => {
201
201
  return {
202
202
  ColumnId,
203
203
  AggFunc: toAggFunc(AggFunc),
204
- TotalColumn,
205
204
  };
206
205
  }),
207
- GrandTotalRow: pivotLayout.GrandTotalRow,
208
- GrandTotalColumn: pivotLayout.GrandTotalColumn,
209
- PivotGroupTotalColumn: pivotLayout.PivotGroupTotalColumn,
210
206
  RowGroupValues: pivotLayout.RowGroupValues
211
207
  ? pivotLayout.RowGroupValues.RowGroupDefaultBehavior === 'always-collapsed' ||
212
208
  pivotLayout.RowGroupValues.RowGroupDefaultBehavior === 'always-expanded'
@@ -330,29 +326,10 @@ export const pivotLayoutModelToPivotLayout = (layoutModel, defaults) => {
330
326
  else {
331
327
  delete pivotLayout.RowGroupValues;
332
328
  }
333
- if (layoutModel.GrandTotalRow) {
334
- pivotLayout.GrandTotalRow = layoutModel.GrandTotalRow;
335
- }
336
- else {
337
- delete pivotLayout.GrandTotalRow;
338
- }
339
- if (layoutModel.GrandTotalColumn) {
340
- pivotLayout.GrandTotalColumn = layoutModel.GrandTotalColumn;
341
- }
342
- else {
343
- delete pivotLayout.GrandTotalColumn;
344
- }
345
- if (layoutModel.PivotGroupTotalColumn) {
346
- pivotLayout.PivotGroupTotalColumn = layoutModel.PivotGroupTotalColumn;
347
- }
348
- else {
349
- delete pivotLayout.PivotGroupTotalColumn;
350
- }
351
329
  if (layoutModel.PivotAggregationColumns) {
352
- pivotLayout.PivotAggregationColumns = (layoutModel.PivotAggregationColumns || []).map(({ ColumnId, AggFunc, TotalColumn }) => ({
330
+ pivotLayout.PivotAggregationColumns = (layoutModel.PivotAggregationColumns || []).map(({ ColumnId, AggFunc }) => ({
353
331
  ColumnId,
354
332
  AggFunc: toAggregationColumnValue(AggFunc),
355
- TotalColumn,
356
333
  }));
357
334
  }
358
335
  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
  }
@@ -187,7 +187,7 @@ export class ColumnFilterInternalApi extends ApiBase {
187
187
  }
188
188
  return true;
189
189
  }
190
- openColumnFilterPopup(columnId) {
190
+ openColumnFilterPopup(columnId, popupProps) {
191
191
  this.getAdaptableInternalApi().showPopupWindow({
192
192
  id: COLUMN_FILTER_WINDOW,
193
193
  title: ModuleConstants.ColumnFilterFriendlyName,
@@ -199,6 +199,7 @@ export class ColumnFilterInternalApi extends ApiBase {
199
199
  width: 380,
200
200
  height: 450,
201
201
  },
202
+ ...popupProps,
202
203
  },
203
204
  });
204
205
  }
@@ -60,6 +60,12 @@ export class CalculatedColumnModule extends AdaptableModuleBase {
60
60
  return (this.api.namedQueryApi.internalApi.getReferencedNamedQueryNames(this.api.expressionApi.getAdaptableQueryExpression(calculatedColumn.Query)) ?? []);
61
61
  }
62
62
  createColumnMenuItems(column) {
63
+ if (!column) {
64
+ return;
65
+ }
66
+ if (!this.isModuleAvailable()) {
67
+ return;
68
+ }
63
69
  if (this.isModuleEditable() && column.isCalculatedColumn) {
64
70
  const popupParam = {
65
71
  column: column,
@@ -72,6 +78,9 @@ export class CalculatedColumnModule extends AdaptableModuleBase {
72
78
  }
73
79
  }
74
80
  createContextMenuItems(menuContext) {
81
+ if (!menuContext.adaptableColumn) {
82
+ return;
83
+ }
75
84
  if (!this.isModuleAvailable()) {
76
85
  return;
77
86
  }
@@ -34,5 +34,5 @@ export const AdaptableFloatingFilter = (props) => {
34
34
  ]);
35
35
  props.onChange?.();
36
36
  }
37
- }, onClear: onClear, columnId: props.Column.columnId, predicate: qlPredicate, predicateDefs: qlPredicateDefs, disabled: columnFilter?.IsSuspended, onPredicateChange: onPredicateChange }));
37
+ }, onClear: onClear, columnId: props.Column.columnId, predicate: qlPredicate, predicateDefs: qlPredicateDefs, disabled: columnFilter?.IsSuspended, onPredicateChange: onPredicateChange, onChange: props.onChange }));
38
38
  };
@@ -12,6 +12,7 @@ export const ColumnFilterWindow = (props) => {
12
12
  React.useEffect(() => {
13
13
  setColumnId(initialColumnId);
14
14
  }, [props.popupProps.value]);
15
+ const onChange = props.popupProps.onChange;
15
16
  return (React.createElement(Flex, { flex: 1, minHeight: 0, height: "100%", flexDirection: "column", p: 2, className: "ab-ColumnFilterWindow" },
16
17
  React.createElement(Box, { mb: 2 },
17
18
  React.createElement(FormLayout, null,
@@ -28,5 +29,5 @@ export const ColumnFilterWindow = (props) => {
28
29
  }
29
30
  return label;
30
31
  }, onChange: (column) => setColumnId(column), filterColumn: (column) => column.queryable, isMulti: false, value: columnId })))),
31
- React.createElement(AdaptableColumnFilter, { columnId: columnId })));
32
+ React.createElement(AdaptableColumnFilter, { columnId: columnId, onChange: onChange })));
32
33
  };
@@ -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>;
@@ -77,7 +77,9 @@ export const FloatingFilter = (props) => {
77
77
  });
78
78
  } }))),
79
79
  isInlineEditable && (React.createElement(SimpleButton, { px: 0, onClick: () => {
80
- adaptable.api.filterApi.columnFilterApi.internalApi.openColumnFilterPopup(props.columnId);
80
+ adaptable.api.filterApi.columnFilterApi.internalApi.openColumnFilterPopup(props.columnId, {
81
+ onChange: props.onChange,
82
+ });
81
83
  }, "data-name": "expand-filter", icon: "expand", variant: "text" })),
82
84
  (isMultiple ||
83
85
  !isPredicateEmpty(props.predicate.args[0], singleFilterPredicateDef)) && (React.createElement(SimpleButton, { "data-name": "clear-filter", p: 0, variant: "text", onClick: handleClear, icon: "close" }))));
@@ -24,7 +24,7 @@ export const ColumnValuesSelect = (props) => {
24
24
  }
25
25
  return true;
26
26
  });
27
- const component = (React.createElement(Select, { isMulti: true, showHeaderSelectionCheckbox: true, searchable: true, closeMenuOnSelect: false, size: "small", menuStyle: {
27
+ const component = (React.createElement(Select, { isMulti: true, showHeaderSelectionCheckbox: true, searchable: true, closeMenuOnSelect: false, menuStyle: {
28
28
  minWidth: `var(--ab-cmp-select-column-menu-${column.columnId}__min-width, var(--ab-cmp-select-column-menu__min-width, 260px))`,
29
29
  }, ...props.selectProps, options: options, value: value, isLoading: props.isLoading, onChange: props.onChange }));
30
30
  return (React.createElement("div", { className: join(baseClassName, props.isLoading && `${baseClassName}--loading`, !value.length && `${baseClassName}--empty`), onKeyDownCapture: (e) => {
package/src/env.js CHANGED
@@ -1,5 +1,5 @@
1
1
  export default {
2
2
  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" || '',
3
- PUBLISH_TIMESTAMP: 1744658441173 || Date.now(),
4
- VERSION: "20.0.4-canary.3" || '--current-version--',
3
+ PUBLISH_TIMESTAMP: 1744726345600 || Date.now(),
4
+ VERSION: "20.0.4" || '--current-version--',
5
5
  };
@@ -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 {};
@@ -3,7 +3,7 @@ import { isPivotLayoutModel } from './isPivotLayoutModel';
3
3
  import { LMEmitter } from './LMEmitter';
4
4
  import { GROUP_COLUMN_ID__MULTI_PREFIX, GROUP_COLUMN_ID__SINGLE, normalizeLayoutModel, normalizePivotLayoutModel, normalizeTableLayoutModel, } from './normalizeLayoutModel';
5
5
  import { isLayoutEqual } from './isLayoutEqual';
6
- import { simplifyLayoutModel, simplifyPivotLayoutModel, simplifyTableLayoutModel, } from './simplifyLayoutModel';
6
+ import { simplifyTableLayoutModel, simplifyPivotLayoutModel, simplifyLayoutModel, } from './simplifyLayoutModel';
7
7
  import { sortColumnIdsByOrder } from './sortColumnIdsByOrder';
8
8
  function flattenColDefs(colDefs) {
9
9
  const res = [];
@@ -117,12 +117,8 @@ export class LayoutManager extends LMEmitter {
117
117
  }).bind(this);
118
118
  }
119
119
  this.setOptions(options);
120
- // this ensures the grand total columns are positioned correctly (before/after) even when changed at runtime
121
- // see https://www.ag-grid.com/react-data-grid/pivoting-column-groups/#changing-data-filters-and-configurations
122
- this.gridApi.setGridOption('enableStrictPivotColumnOrder', true);
123
120
  this.setupEvents();
124
121
  this.indexColumns();
125
- this.setupPivotTotals();
126
122
  globalThis.layoutManager = this;
127
123
  }
128
124
  destroy() {
@@ -256,18 +252,6 @@ export class LayoutManager extends LMEmitter {
256
252
  PivotAggregationColumns: layout.TableAggregationColumns,
257
253
  PivotExpandLevel: prevLayout?.PivotExpandLevel ?? -1,
258
254
  };
259
- const grandTotalRow = this.gridApi.getGridOption('grandTotalRow');
260
- if (grandTotalRow) {
261
- pivotLayout.GrandTotalRow = grandTotalRow;
262
- }
263
- const grandTotalColumn = this.gridApi.getGridOption('pivotRowTotals');
264
- if (grandTotalColumn) {
265
- pivotLayout.GrandTotalColumn = grandTotalColumn;
266
- }
267
- const pivotGroupTotalColumn = this.gridApi.getGridOption('pivotColumnGroupTotals');
268
- if (pivotGroupTotalColumn) {
269
- pivotLayout.PivotGroupTotalColumn = pivotGroupTotalColumn;
270
- }
271
255
  return simplifyPivotLayoutModel(pivotLayout);
272
256
  }
273
257
  getTableLayoutModelFromGrid() {
@@ -288,7 +272,7 @@ export class LayoutManager extends LMEmitter {
288
272
  let ColumnPinning = {};
289
273
  const gridState = this.gridApi.getState();
290
274
  const prevLayout = this.currentLayout;
291
- const prevAggColumns = prevLayout?.TableAggregationColumns ?? prevLayout?.PivotAggregationColumns;
275
+ const prevAggColumns = prevLayout?.TableAggregationColumns;
292
276
  const prevAggColumnsMap = prevAggColumns?.reduce((acc, agg) => {
293
277
  acc[agg.ColumnId] = agg;
294
278
  return acc;
@@ -999,7 +983,6 @@ export class LayoutManager extends LMEmitter {
999
983
  return columnIds;
1000
984
  }
1001
985
  applyPivotLayout(layout, options) {
1002
- this.applyPivotTotals(layout);
1003
986
  const columnState = this.computeColumnStateForPivotLayout(layout);
1004
987
  // by simply calling this.gridApi.applyColumnState(columnState)
1005
988
  // the order of aggregations is not preserved/guaranteed by ag-grid
@@ -1027,50 +1010,6 @@ export class LayoutManager extends LMEmitter {
1027
1010
  this.applyRowGroupValues(layout.RowGroupValues);
1028
1011
  }
1029
1012
  }
1030
- applyPivotTotals(layout) {
1031
- /**
1032
- * GrandTotalRow
1033
- */
1034
- if (layout.GrandTotalRow) {
1035
- const grandTotalRow = layout.GrandTotalRow === true || layout.GrandTotalRow === 'top'
1036
- ? 'top'
1037
- : layout.GrandTotalRow === 'bottom'
1038
- ? 'bottom'
1039
- : null;
1040
- this.gridApi.setGridOption('grandTotalRow', grandTotalRow);
1041
- }
1042
- else {
1043
- this.gridApi.setGridOption('grandTotalRow', null);
1044
- }
1045
- /**
1046
- * GrandTotalColumn
1047
- */
1048
- if (layout.GrandTotalColumn) {
1049
- const grandTotalColumn = layout.GrandTotalColumn === true || layout.GrandTotalColumn === 'before'
1050
- ? 'before'
1051
- : layout.GrandTotalColumn === 'after'
1052
- ? 'after'
1053
- : null;
1054
- this.gridApi.setGridOption('pivotRowTotals', grandTotalColumn);
1055
- }
1056
- else {
1057
- this.gridApi.setGridOption('pivotRowTotals', null);
1058
- }
1059
- /**
1060
- * PivotGroupTotalColumn
1061
- */
1062
- if (layout.PivotGroupTotalColumn) {
1063
- const pivotGroupTotalColumn = layout.PivotGroupTotalColumn === true || layout.PivotGroupTotalColumn === 'before'
1064
- ? 'before'
1065
- : layout.PivotGroupTotalColumn === 'after'
1066
- ? 'after'
1067
- : null;
1068
- this.gridApi.setGridOption('pivotColumnGroupTotals', pivotGroupTotalColumn);
1069
- }
1070
- else {
1071
- this.gridApi.setGridOption('pivotColumnGroupTotals', null);
1072
- }
1073
- }
1074
1013
  applyPivotExpandLevel(layout) {
1075
1014
  const PivotExpandLevel = layout.PivotExpandLevel ?? -1;
1076
1015
  const allDisplayedColumnGroups = this.gridApi.getAllDisplayedColumnGroups();
@@ -1106,165 +1045,4 @@ export class LayoutManager extends LMEmitter {
1106
1045
  }
1107
1046
  return res;
1108
1047
  }
1109
- setupPivotTotals() {
1110
- const _original_processPivotResultColDef = this.gridApi.getGridOption('processPivotResultColDef');
1111
- this.gridApi.setGridOption('processPivotResultColDef', (resulColDef) => {
1112
- _original_processPivotResultColDef?.(resulColDef);
1113
- if (!isPivotLayoutModel(this.currentLayout)) {
1114
- return;
1115
- }
1116
- this.patchGrandTotalColumn(resulColDef);
1117
- this.patchPivotGroupTotalColumn(resulColDef);
1118
- });
1119
- const _original_processPivotResultColGroupDef = this.gridApi.getGridOption('processPivotResultColGroupDef');
1120
- this.gridApi.setGridOption('processPivotResultColGroupDef', (colGroupDef) => {
1121
- _original_processPivotResultColGroupDef?.(colGroupDef);
1122
- if (!isPivotLayoutModel(this.currentLayout)) {
1123
- return;
1124
- }
1125
- this.patchPivotTotalColumn(colGroupDef);
1126
- });
1127
- }
1128
- isPivotRowTotalColDef(colDef) {
1129
- return colDef.colId?.startsWith('PivotRowTotal_');
1130
- }
1131
- patchGrandTotalColumn(resultColDef) {
1132
- if (!isPivotLayoutModel(this.currentLayout) || !this.currentLayout.GrandTotalColumn) {
1133
- return;
1134
- }
1135
- if (this.isPivotRowTotalColDef(resultColDef)) {
1136
- resultColDef.headerName = `Grand Total ${resultColDef.headerName}`;
1137
- }
1138
- }
1139
- isPivotGroupTotalColumn(colDef) {
1140
- // pivot group total are spanning cross all aggregations
1141
- // therefore the last part of the colId is empty (hence the "dangling" underscore)
1142
- return colDef.colId?.startsWith('pivot_') && colDef.colId?.endsWith('_');
1143
- }
1144
- patchPivotGroupTotalColumn(resultColDef) {
1145
- if (!isPivotLayoutModel(this.currentLayout) || !this.currentLayout.PivotGroupTotalColumn) {
1146
- return;
1147
- }
1148
- if (this.isPivotGroupTotalColumn(resultColDef)) {
1149
- // resultColDef
1150
- const colInfo = this.destructurePivotColumnId(resultColDef.colId);
1151
- if (colInfo !== '!unknown!') {
1152
- const currentPivotKey = colInfo.pivotKeys[colInfo.pivotKeys.length - 1];
1153
- resultColDef.headerName = `${currentPivotKey} Total`;
1154
- }
1155
- }
1156
- }
1157
- patchPivotTotalColumn(colGroupDef) {
1158
- const hasPivotTotalCols = (pivotLayout) => {
1159
- return pivotLayout.PivotAggregationColumns?.some((aggCol) => !!aggCol.TotalColumn);
1160
- };
1161
- const isPivotTotalColDef = (colDef) => {
1162
- return !!colDef.pivotTotalColumnIds?.length;
1163
- };
1164
- if (!isPivotLayoutModel(this.currentLayout) || !hasPivotTotalCols(this.currentLayout)) {
1165
- return;
1166
- }
1167
- const pivotRowTotalColDefsBefore = [];
1168
- const pivotRowTotalColDefsAfter = [];
1169
- const pivotTotalColDefsBefore = [];
1170
- const pivotTotalColDefsAfter = [];
1171
- const normalColDefs = [];
1172
- colGroupDef.children.forEach((colDef) => {
1173
- if (this.isPivotRowTotalColDef(colDef)) {
1174
- if (this.gridApi.getGridOption('pivotRowTotals') === 'after') {
1175
- pivotRowTotalColDefsAfter.push(colDef);
1176
- }
1177
- else {
1178
- pivotRowTotalColDefsBefore.push(colDef);
1179
- }
1180
- return;
1181
- }
1182
- if (isPivotTotalColDef(colDef)) {
1183
- if (!colDef.colId.startsWith('pivot_')) {
1184
- this.warn(`Pivot total column ${colDef.colId} is not prefixed with 'pivot_', skipping...`);
1185
- return;
1186
- }
1187
- // we do this for all total cols, but we will hide the ones that are not visible
1188
- colDef.columnGroupShow = undefined;
1189
- colDef.headerName = `Total ${colDef.headerName}`;
1190
- const totalColConfig = this.getPivotTotalColumnConfig(colDef, this.currentLayout);
1191
- if (!totalColConfig.visible) {
1192
- colDef.hide = true;
1193
- }
1194
- else {
1195
- if (totalColConfig.position === 'after') {
1196
- pivotTotalColDefsAfter.push(colDef);
1197
- }
1198
- else {
1199
- pivotTotalColDefsBefore.push(colDef);
1200
- }
1201
- }
1202
- }
1203
- else {
1204
- normalColDefs.push(colDef);
1205
- }
1206
- });
1207
- colGroupDef.children = [
1208
- ...pivotRowTotalColDefsBefore,
1209
- ...pivotTotalColDefsBefore,
1210
- ...normalColDefs,
1211
- ...pivotTotalColDefsAfter,
1212
- ...pivotRowTotalColDefsAfter,
1213
- ];
1214
- }
1215
- destructurePivotColumnId(colId = '') {
1216
- // Split by underscore to get 4 parts
1217
- const parts = colId.split('_');
1218
- if (parts.length !== 4) {
1219
- this.warn(`Unsupported format of pivot total column id: ${colId}`);
1220
- return '!unknown!';
1221
- }
1222
- // e.g.
1223
- // pivot_country-sport-year_United States-Basketball_gold
1224
- // pivotColumnIds: ['country', 'sport', 'year']
1225
- // pivotKeys: ['United States', 'Basketball']
1226
- // aggregationColumnId: 'gold'
1227
- const [_pivotPrefix, pivotColsTxt, pivotKeysTxt, aggregationColumnId] = parts;
1228
- const pivotColumnIds = pivotColsTxt.split('-');
1229
- const pivotKeys = pivotKeysTxt.split('-');
1230
- const pivotColumnId = pivotColumnIds[pivotKeys.length - 1];
1231
- return {
1232
- pivotColumnIds,
1233
- pivotKeys,
1234
- pivotColumnId,
1235
- aggregationColumnId,
1236
- };
1237
- }
1238
- getPivotTotalColumnConfig(colDef, currentPivotLayout) {
1239
- const defaultHiddenConfig = {
1240
- visible: false,
1241
- };
1242
- const colIdInfo = this.destructurePivotColumnId(colDef.colId);
1243
- if (colIdInfo === '!unknown!') {
1244
- return defaultHiddenConfig;
1245
- }
1246
- const { pivotColumnId, aggregationColumnId } = colIdInfo;
1247
- const layoutAggCol = currentPivotLayout.PivotAggregationColumns?.find((col) => col.ColumnId === aggregationColumnId);
1248
- if (!layoutAggCol) {
1249
- this.warn(`Pivot Totals: could NOT find aggregation(value) column with id ${aggregationColumnId}`);
1250
- return defaultHiddenConfig;
1251
- }
1252
- const layoutPivotTotalColumn = layoutAggCol.TotalColumn;
1253
- if (!layoutPivotTotalColumn) {
1254
- return defaultHiddenConfig;
1255
- }
1256
- if (Array.isArray(layoutPivotTotalColumn)) {
1257
- const pivotSpecificConfig = layoutPivotTotalColumn.find((config) => config.PivotColumnId === pivotColumnId);
1258
- return {
1259
- visible: pivotSpecificConfig && pivotSpecificConfig.ShowTotal !== false,
1260
- position: pivotSpecificConfig?.ShowTotal === 'after' ? 'after' : 'before',
1261
- };
1262
- }
1263
- else {
1264
- return {
1265
- visible: !!layoutPivotTotalColumn,
1266
- position: layoutPivotTotalColumn === 'after' ? 'after' : 'before',
1267
- };
1268
- }
1269
- }
1270
1048
  }
@@ -139,9 +139,6 @@ export function normalizePivotLayoutModel(layout) {
139
139
  // make it an own property
140
140
  layout.SuppressAggFuncInHeader = undefined;
141
141
  }
142
- if (!layout.GrandTotalRow) {
143
- layout.GrandTotalRow = false;
144
- }
145
142
  return layout;
146
143
  }
147
144
  export function normalizeLayoutModel(layout, options) {
@@ -15,7 +15,7 @@ export function simplifyTableLayoutModel(layout) {
15
15
  delete layout.RowGroupedColumns;
16
16
  }
17
17
  if (!layout.RowGroupedColumns && layout.RowGroupValues) {
18
- delete layout.RowGroupValues;
18
+ // delete layout.RowGroupValues;
19
19
  }
20
20
  if (layout.SuppressAggFuncInHeader === undefined) {
21
21
  delete layout.SuppressAggFuncInHeader;