@adaptabletools/adaptable 20.0.2 → 20.0.3-canary.0
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 +1 -1
- package/src/AdaptableOptions/FilterOptions.d.ts +1 -1
- package/src/AdaptableState/LayoutState.d.ts +1 -1
- package/src/Api/Implementation/LayoutHelpers.js +63 -1
- package/src/Api/Internal/LayoutInternalApi.js +1 -1
- package/src/Redux/Store/AdaptableStore.js +3 -2
- package/src/View/Components/Selectors/BulkUpdateValueSelector.js +3 -3
- package/src/agGrid/AdaptableAgGrid.js +4 -9
- package/src/agGrid/getAgGridFilterNotifyModelFn.d.ts +1 -1
- package/src/agGrid/getAgGridFilterNotifyModelFn.js +12 -6
- package/src/env.js +2 -2
- package/src/layout-manager/src/LayoutManagerModel.d.ts +11 -0
- package/src/layout-manager/src/index.js +50 -44
- package/src/layout-manager/src/simplifyLayoutModel.js +1 -1
- package/src/metamodel/adaptable.metamodel.js +1 -1
- package/tsconfig.esm.tsbuildinfo +1 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@adaptabletools/adaptable",
|
|
3
|
-
"version": "20.0.
|
|
3
|
+
"version": "20.0.3-canary.0",
|
|
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",
|
|
@@ -26,7 +26,7 @@ export interface FilterOptions<TData = any> {
|
|
|
26
26
|
*/
|
|
27
27
|
clearFiltersOnStartUp?: boolean;
|
|
28
28
|
/**
|
|
29
|
-
* Provide custom values (or sorting / count
|
|
29
|
+
* Provide custom values (or sorting / count info) when using the `In` Filter
|
|
30
30
|
* @param context
|
|
31
31
|
* @returns
|
|
32
32
|
*/
|
|
@@ -51,7 +51,7 @@ export interface LayoutBase extends AdaptableObject {
|
|
|
51
51
|
*/
|
|
52
52
|
ColumnHeaders?: ColumnStringMap;
|
|
53
53
|
/**
|
|
54
|
-
* Hides aggFunc
|
|
54
|
+
* Hides the aggFunc in Column header: e.g. 'sum(Price)' becomes 'Price'
|
|
55
55
|
*/
|
|
56
56
|
SuppressAggFuncInHeader?: boolean;
|
|
57
57
|
/**
|
|
@@ -62,6 +62,8 @@ export const normalizeTableLayout = (tableLayout, options) => {
|
|
|
62
62
|
const Source = tableLayout.Source;
|
|
63
63
|
const Uuid = tableLayout.Uuid;
|
|
64
64
|
const AdaptableVersion = tableLayout.AdaptableVersion;
|
|
65
|
+
const ColumnFilters = tableLayout.ColumnFilters;
|
|
66
|
+
const GridFilter = tableLayout.GridFilter;
|
|
65
67
|
let model = tableLayoutToTableLayoutModel(tableLayout);
|
|
66
68
|
model = normalizeTableLayoutModel(model, options);
|
|
67
69
|
tableLayout = tableLayoutModelToTableLayout(model, tableLayout);
|
|
@@ -74,12 +76,20 @@ export const normalizeTableLayout = (tableLayout, options) => {
|
|
|
74
76
|
if (AdaptableVersion) {
|
|
75
77
|
tableLayout.AdaptableVersion = AdaptableVersion;
|
|
76
78
|
}
|
|
79
|
+
if (ColumnFilters) {
|
|
80
|
+
tableLayout.ColumnFilters = ColumnFilters;
|
|
81
|
+
}
|
|
82
|
+
if (GridFilter) {
|
|
83
|
+
tableLayout.GridFilter = GridFilter;
|
|
84
|
+
}
|
|
77
85
|
return tableLayout;
|
|
78
86
|
};
|
|
79
87
|
export const normalizePivotLayout = (pivotLayout) => {
|
|
80
88
|
const Source = pivotLayout.Source;
|
|
81
89
|
const Uuid = pivotLayout.Uuid;
|
|
82
90
|
const AdaptableVersion = pivotLayout.AdaptableVersion;
|
|
91
|
+
const ColumnFilters = pivotLayout.ColumnFilters;
|
|
92
|
+
const GridFilter = pivotLayout.GridFilter;
|
|
83
93
|
let model = pivotLayoutToPivotLayoutModel(pivotLayout);
|
|
84
94
|
model = normalizePivotLayoutModel(model);
|
|
85
95
|
pivotLayout = pivotLayoutModelToPivotLayout(model, pivotLayout);
|
|
@@ -92,6 +102,12 @@ export const normalizePivotLayout = (pivotLayout) => {
|
|
|
92
102
|
if (AdaptableVersion) {
|
|
93
103
|
pivotLayout.AdaptableVersion = AdaptableVersion;
|
|
94
104
|
}
|
|
105
|
+
if (ColumnFilters) {
|
|
106
|
+
pivotLayout.ColumnFilters = ColumnFilters;
|
|
107
|
+
}
|
|
108
|
+
if (GridFilter) {
|
|
109
|
+
pivotLayout.GridFilter = GridFilter;
|
|
110
|
+
}
|
|
95
111
|
return pivotLayout;
|
|
96
112
|
};
|
|
97
113
|
const errorOnceMessages = new Map();
|
|
@@ -160,6 +176,12 @@ export const tableLayoutToTableLayoutModel = (tableLayout) => {
|
|
|
160
176
|
if (tableLayout.RowGroupDisplayType) {
|
|
161
177
|
result.RowGroupDisplayType = tableLayout.RowGroupDisplayType;
|
|
162
178
|
}
|
|
179
|
+
if (tableLayout.ColumnFilters) {
|
|
180
|
+
result.ColumnFilters = tableLayout.ColumnFilters;
|
|
181
|
+
}
|
|
182
|
+
if (tableLayout.GridFilter) {
|
|
183
|
+
result.GridFilter = tableLayout.GridFilter;
|
|
184
|
+
}
|
|
163
185
|
return result;
|
|
164
186
|
};
|
|
165
187
|
export const pivotLayoutToPivotLayoutModel = (pivotLayout) => {
|
|
@@ -181,7 +203,24 @@ export const pivotLayoutToPivotLayoutModel = (pivotLayout) => {
|
|
|
181
203
|
AggFunc: toAggFunc(AggFunc),
|
|
182
204
|
};
|
|
183
205
|
}),
|
|
206
|
+
RowGroupValues: pivotLayout.RowGroupValues
|
|
207
|
+
? pivotLayout.RowGroupValues.RowGroupDefaultBehavior === 'always-collapsed' ||
|
|
208
|
+
pivotLayout.RowGroupValues.RowGroupDefaultBehavior === 'always-expanded'
|
|
209
|
+
? {
|
|
210
|
+
RowGroupDisplay: pivotLayout.RowGroupValues.RowGroupDefaultBehavior,
|
|
211
|
+
}
|
|
212
|
+
: {
|
|
213
|
+
RowGroupDisplay: pivotLayout.RowGroupValues.RowGroupDefaultBehavior,
|
|
214
|
+
Values: pivotLayout.RowGroupValues.ExceptionGroupKeys || [],
|
|
215
|
+
}
|
|
216
|
+
: undefined,
|
|
184
217
|
});
|
|
218
|
+
if (pivotLayout.ColumnFilters) {
|
|
219
|
+
result.ColumnFilters = pivotLayout.ColumnFilters;
|
|
220
|
+
}
|
|
221
|
+
if (pivotLayout.GridFilter) {
|
|
222
|
+
result.GridFilter = pivotLayout.GridFilter;
|
|
223
|
+
}
|
|
185
224
|
return result;
|
|
186
225
|
};
|
|
187
226
|
function toAggFunc(aggFunc) {
|
|
@@ -238,6 +277,12 @@ export const tableLayoutModelToTableLayout = (layoutModel, defaults) => {
|
|
|
238
277
|
else {
|
|
239
278
|
delete tableLayout.TableAggregationColumns;
|
|
240
279
|
}
|
|
280
|
+
if (layoutModel.ColumnFilters) {
|
|
281
|
+
tableLayout.ColumnFilters = layoutModel.ColumnFilters;
|
|
282
|
+
}
|
|
283
|
+
if (layoutModel.GridFilter) {
|
|
284
|
+
tableLayout.GridFilter = layoutModel.GridFilter;
|
|
285
|
+
}
|
|
241
286
|
cleanupAdaptableObjectPrimitives(tableLayout);
|
|
242
287
|
return tableLayout;
|
|
243
288
|
};
|
|
@@ -267,7 +312,18 @@ export const pivotLayoutModelToPivotLayout = (layoutModel, defaults) => {
|
|
|
267
312
|
else {
|
|
268
313
|
delete pivotLayout.PivotGroupedColumns;
|
|
269
314
|
}
|
|
270
|
-
if (
|
|
315
|
+
if (layoutModel.RowGroupValues) {
|
|
316
|
+
pivotLayout.RowGroupValues = {
|
|
317
|
+
RowGroupDefaultBehavior: layoutModel.RowGroupValues.RowGroupDisplay,
|
|
318
|
+
};
|
|
319
|
+
if ((layoutModel.RowGroupValues.RowGroupDisplay === 'collapsed' ||
|
|
320
|
+
layoutModel.RowGroupValues.RowGroupDisplay === 'expanded') &&
|
|
321
|
+
layoutModel.RowGroupValues.Values) {
|
|
322
|
+
// @ts-ignore
|
|
323
|
+
pivotLayout.RowGroupValues.ExceptionGroupKeys = layoutModel.RowGroupValues.Values;
|
|
324
|
+
}
|
|
325
|
+
}
|
|
326
|
+
else {
|
|
271
327
|
delete pivotLayout.RowGroupValues;
|
|
272
328
|
}
|
|
273
329
|
if (layoutModel.PivotAggregationColumns) {
|
|
@@ -279,6 +335,12 @@ export const pivotLayoutModelToPivotLayout = (layoutModel, defaults) => {
|
|
|
279
335
|
else {
|
|
280
336
|
delete pivotLayout.PivotAggregationColumns;
|
|
281
337
|
}
|
|
338
|
+
if (layoutModel.ColumnFilters) {
|
|
339
|
+
pivotLayout.ColumnFilters = layoutModel.ColumnFilters;
|
|
340
|
+
}
|
|
341
|
+
if (layoutModel.GridFilter) {
|
|
342
|
+
pivotLayout.GridFilter = layoutModel.GridFilter;
|
|
343
|
+
}
|
|
282
344
|
return pivotLayout;
|
|
283
345
|
};
|
|
284
346
|
export const isPivotLayout = (layout) => Array.isArray(layout.PivotColumns);
|
|
@@ -148,7 +148,7 @@ export class LayoutInternalApi extends ApiBase {
|
|
|
148
148
|
if (!layout) {
|
|
149
149
|
layout = this.getLayoutApi().getCurrentLayout();
|
|
150
150
|
}
|
|
151
|
-
return layout?.RowGroupedColumns?.length > 0;
|
|
151
|
+
return (layout?.RowGroupedColumns?.length || layout?.PivotGroupedColumns?.length) > 0;
|
|
152
152
|
}
|
|
153
153
|
setupRowSummaries() {
|
|
154
154
|
const rowSummaries = this.getAdaptableState().Internal?.RowSummary?.rowSummaries ?? [];
|
|
@@ -923,7 +923,8 @@ const adaptableMiddleware = (adaptable) => (function(middlewareAPI) {
|
|
|
923
923
|
* Action: Apply Column Filtering and fire associated events
|
|
924
924
|
*/
|
|
925
925
|
case LayoutRedux.LAYOUT_COLUMN_FILTER_ADD:
|
|
926
|
-
|
|
926
|
+
// see ref "also-this-handles-the-LAYOUT_COLUMN_FILTER_EDIT-case"
|
|
927
|
+
// case LayoutRedux.LAYOUT_COLUMN_FILTER_EDIT:
|
|
927
928
|
case LayoutRedux.LAYOUT_COLUMN_FILTER_SET:
|
|
928
929
|
case LayoutRedux.LAYOUT_COLUMN_FILTER_CLEAR:
|
|
929
930
|
case LayoutRedux.LAYOUT_COLUMN_FILTER_CLEAR_ALL:
|
|
@@ -940,7 +941,7 @@ const adaptableMiddleware = (adaptable) => (function(middlewareAPI) {
|
|
|
940
941
|
if (shouldTriggerColumnFiltering) {
|
|
941
942
|
adaptable.applyFiltering();
|
|
942
943
|
}
|
|
943
|
-
},
|
|
944
|
+
}, 50);
|
|
944
945
|
adaptable.api.eventApi.internalApi.fireColumnFilterAppliedEvent();
|
|
945
946
|
adaptable.api.eventApi.internalApi.fireLayoutChangedEvent(action.type, oldLayoutState, middlewareAPI.getState().Layout);
|
|
946
947
|
return returnAction;
|
|
@@ -18,7 +18,7 @@ export const BulkUpdateValueSelector = (props) => {
|
|
|
18
18
|
// not sure that we need to
|
|
19
19
|
const permittedValueSelector = (React.createElement(Box, null,
|
|
20
20
|
React.createElement(PermittedValuesSelector, { allowNewValues: true, disabled: props.disabled || !props.selectedColumn, value: props.selectedColumnValue === '' ? null : props.selectedColumnValue, columnId: columnId, placeholder: isDateType ? 'Select' : 'Select or type new value', loadValues: useCallback(({ currentSearchValue }) => {
|
|
21
|
-
if (!columnId) {
|
|
21
|
+
if (!columnId || !props.selectedGridCells.length) {
|
|
22
22
|
return Promise.resolve([]);
|
|
23
23
|
}
|
|
24
24
|
return adaptable.api.gridApi.internalApi.getDistinctEditDisplayValuesForColumn({
|
|
@@ -28,8 +28,8 @@ export const BulkUpdateValueSelector = (props) => {
|
|
|
28
28
|
});
|
|
29
29
|
}, [
|
|
30
30
|
columnId,
|
|
31
|
-
props.selectedGridCells[0]?.column.columnId,
|
|
32
|
-
props.selectedGridCells[0]?.primaryKeyValue,
|
|
31
|
+
props.selectedGridCells?.[0]?.column.columnId,
|
|
32
|
+
props.selectedGridCells?.[0]?.primaryKeyValue,
|
|
33
33
|
]), onChange: (value) => {
|
|
34
34
|
props.onColumnValueChange(value || null);
|
|
35
35
|
} })));
|
|
@@ -90,7 +90,7 @@ import { weightedAverage } from '../Utilities/weightedAverage';
|
|
|
90
90
|
import { ROW_SUMMARY_ROW_ID } from '../AdaptableState/Common/RowSummary';
|
|
91
91
|
import { FlashingCellService } from '../Utilities/Services/FlashingCellService';
|
|
92
92
|
import { AgGridExportAdapter } from './AgGridExportAdapter';
|
|
93
|
-
import { checkForDuplicateColumns, isPivotLayout, layoutModelToLayoutState, layoutStateToLayoutModel, normalizeLayout,
|
|
93
|
+
import { checkForDuplicateColumns, isPivotLayout, layoutModelToLayoutState, layoutStateToLayoutModel, normalizeLayout, } from '../Api/Implementation/LayoutHelpers';
|
|
94
94
|
import { LayoutManager } from '../layout-manager/src';
|
|
95
95
|
import { isPivotLayoutModel } from '../layout-manager/src/isPivotLayoutModel';
|
|
96
96
|
import { ACTION_COLUMN_TYPE, CALCULATED_COLUMN_TYPE, FDC3_COLUMN_TYPE, FREE_TEXT_COLUMN_TYPE, } from '../AdaptableState/Common/AdaptableColumn';
|
|
@@ -441,9 +441,7 @@ export class AdaptableAgGrid {
|
|
|
441
441
|
// see test /tests/pages/quick-search/pivot-search.spec.ts
|
|
442
442
|
this.updateColumnModelAndRefreshGrid();
|
|
443
443
|
}
|
|
444
|
-
|
|
445
|
-
this.layoutManager.applyRowGroupValues(layoutStateToLayoutModel(currentLayout).RowGroupValues);
|
|
446
|
-
}
|
|
444
|
+
this.layoutManager.applyRowGroupValues(layoutStateToLayoutModel(currentLayout).RowGroupValues);
|
|
447
445
|
this.autoSizeLayoutIfNeeded();
|
|
448
446
|
this.ModuleService.createModuleUIItems();
|
|
449
447
|
const adaptableContainerElem = this.getAdaptableContainerElement();
|
|
@@ -1886,11 +1884,8 @@ You need to define at least one Layout!`);
|
|
|
1886
1884
|
if (!layout) {
|
|
1887
1885
|
layout = this.api.layoutApi.getCurrentLayout();
|
|
1888
1886
|
}
|
|
1889
|
-
|
|
1890
|
-
|
|
1891
|
-
this.layoutManager.applyRowGroupValues(layoutModel.RowGroupValues);
|
|
1892
|
-
return;
|
|
1893
|
-
}
|
|
1887
|
+
const layoutModel = layoutStateToLayoutModel(layout);
|
|
1888
|
+
this.layoutManager.applyRowGroupValues(layoutModel.RowGroupValues);
|
|
1894
1889
|
}
|
|
1895
1890
|
isGroupRowNode(rowNode) {
|
|
1896
1891
|
if (!rowNode) {
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { AdaptableApi } from '../types';
|
|
2
|
-
export declare function getAgGridFilterNotifyModelFn(adaptableApi: AdaptableApi, colId: string, onModelChange: (model: any) => void): () => void
|
|
2
|
+
export declare function getAgGridFilterNotifyModelFn(adaptableApi: AdaptableApi, colId: string, onModelChange: (model: any) => void): import("lodash").DebouncedFunc<() => void>;
|
|
@@ -1,10 +1,16 @@
|
|
|
1
|
+
import debounce from 'lodash/debounce';
|
|
1
2
|
export function getAgGridFilterNotifyModelFn(adaptableApi, colId, onModelChange) {
|
|
2
|
-
const notifyModel = () => {
|
|
3
|
+
const notifyModel = debounce(() => {
|
|
3
4
|
const isActive = adaptableApi.filterApi.columnFilterApi.isColumnFilterActiveForColumn(colId);
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
5
|
+
setTimeout(() => {
|
|
6
|
+
// call it with non null to indicate that the filter is active
|
|
7
|
+
// call it with null to indicate that the filter is not active
|
|
8
|
+
// as per the AG Grid documentation
|
|
9
|
+
// ref: also-this-handles-the-LAYOUT_COLUMN_FILTER_EDIT-case
|
|
10
|
+
onModelChange(isActive ? true : null);
|
|
11
|
+
}, 50);
|
|
12
|
+
}, 50, {
|
|
13
|
+
trailing: true,
|
|
14
|
+
});
|
|
9
15
|
return notifyModel;
|
|
10
16
|
}
|
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:
|
|
4
|
-
VERSION: "20.0.
|
|
3
|
+
PUBLISH_TIMESTAMP: 1743753777733 || Date.now(),
|
|
4
|
+
VERSION: "20.0.3-canary.0" || '--current-version--',
|
|
5
5
|
};
|
|
@@ -12,6 +12,17 @@ export interface ColumnSortModel {
|
|
|
12
12
|
SortOrder: 'Asc' | 'Desc';
|
|
13
13
|
}
|
|
14
14
|
export interface BaseLayoutModel {
|
|
15
|
+
/**
|
|
16
|
+
* Those are not actually used by the LayoutManager,
|
|
17
|
+
* but we need to keep them here so we can give the layout
|
|
18
|
+
* fully specified back to Adaptable, with this prop
|
|
19
|
+
* set as it was when we received it from Adaptable
|
|
20
|
+
*/
|
|
21
|
+
ColumnFilters?: any;
|
|
22
|
+
/**
|
|
23
|
+
* Same as ColumnFilters, but for Grid Filter
|
|
24
|
+
*/
|
|
25
|
+
GridFilter?: any;
|
|
15
26
|
ColumnVisibility?: {
|
|
16
27
|
[columnId: string]: false;
|
|
17
28
|
};
|
|
@@ -268,7 +268,7 @@ export class LayoutManager extends LMEmitter {
|
|
|
268
268
|
let ColumnSorts = [];
|
|
269
269
|
let RowGroupedColumns = [];
|
|
270
270
|
let RowGroupValues = undefined;
|
|
271
|
-
let
|
|
271
|
+
let TableAggregationColumns = [];
|
|
272
272
|
let ColumnPinning = {};
|
|
273
273
|
const gridState = this.gridApi.getState();
|
|
274
274
|
const prevLayout = this.currentLayout;
|
|
@@ -318,7 +318,7 @@ export class LayoutManager extends LMEmitter {
|
|
|
318
318
|
return acc;
|
|
319
319
|
}, {});
|
|
320
320
|
if (gridState.aggregation) {
|
|
321
|
-
|
|
321
|
+
TableAggregationColumns = gridState.aggregation.aggregationModel.map((agg) => {
|
|
322
322
|
const prevAggForColumn = prevAggColumnsMap?.[agg.colId];
|
|
323
323
|
if (prevAggForColumn && prevAggForColumn.AggFunc.aggFunc === agg.aggFunc) {
|
|
324
324
|
return prevAggForColumn;
|
|
@@ -380,7 +380,7 @@ export class LayoutManager extends LMEmitter {
|
|
|
380
380
|
delete ColumnVisibility[colId];
|
|
381
381
|
}
|
|
382
382
|
});
|
|
383
|
-
|
|
383
|
+
TableAggregationColumns = TableAggregationColumns.filter((agg) => {
|
|
384
384
|
if (columnOrderSet.has(agg.ColumnId)) {
|
|
385
385
|
return true;
|
|
386
386
|
}
|
|
@@ -431,7 +431,7 @@ export class LayoutManager extends LMEmitter {
|
|
|
431
431
|
ColumnWidths: ColumnWidths,
|
|
432
432
|
ColumnSorts,
|
|
433
433
|
RowGroupedColumns,
|
|
434
|
-
TableAggregationColumns
|
|
434
|
+
TableAggregationColumns,
|
|
435
435
|
ColumnPinning: ColumnPinning,
|
|
436
436
|
RowGroupValues,
|
|
437
437
|
});
|
|
@@ -676,7 +676,7 @@ export class LayoutManager extends LMEmitter {
|
|
|
676
676
|
try {
|
|
677
677
|
const perfApplyPivot = this.beginPerf('applyLayout:pivot');
|
|
678
678
|
this.gridApi.setGridOption('pivotMode', true);
|
|
679
|
-
this.applyPivotLayout(layout);
|
|
679
|
+
this.applyPivotLayout(layout, options);
|
|
680
680
|
perfApplyPivot.end();
|
|
681
681
|
}
|
|
682
682
|
finally {
|
|
@@ -737,44 +737,45 @@ export class LayoutManager extends LMEmitter {
|
|
|
737
737
|
return result;
|
|
738
738
|
}
|
|
739
739
|
applyRowGroupValues(RowGroupValues) {
|
|
740
|
-
if (RowGroupValues) {
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
}
|
|
740
|
+
if (!RowGroupValues) {
|
|
741
|
+
return;
|
|
742
|
+
}
|
|
743
|
+
if (RowGroupValues.RowGroupDisplay === 'always-expanded') {
|
|
744
|
+
this.gridApi.expandAll();
|
|
745
|
+
return;
|
|
746
|
+
}
|
|
747
|
+
if (RowGroupValues.RowGroupDisplay === 'always-collapsed') {
|
|
748
|
+
this.gridApi.collapseAll();
|
|
749
|
+
return;
|
|
750
|
+
}
|
|
751
|
+
const defaultExpanded = RowGroupValues.RowGroupDisplay === 'expanded';
|
|
752
|
+
if (RowGroupValues.Values) {
|
|
753
|
+
const deepMap = new DeepMap();
|
|
754
|
+
RowGroupValues.Values.forEach((rowGroupValue) => {
|
|
755
|
+
deepMap.set(rowGroupValue, true);
|
|
756
|
+
});
|
|
757
|
+
this.gridApi.forEachNode((node) => {
|
|
758
|
+
if (!node.group) {
|
|
759
|
+
return;
|
|
760
|
+
}
|
|
761
|
+
if (node.group) {
|
|
762
|
+
const nodePath = [];
|
|
763
|
+
let currentNode = node;
|
|
764
|
+
do {
|
|
765
|
+
nodePath.unshift(currentNode.key);
|
|
766
|
+
currentNode = currentNode.parent;
|
|
767
|
+
} while (currentNode.parent);
|
|
768
|
+
const shouldBeExpanded = defaultExpanded
|
|
769
|
+
? // by default nodes should be expanded
|
|
770
|
+
// but this node should be expanded if it is not in the map
|
|
771
|
+
!deepMap.has(nodePath)
|
|
772
|
+
: // by default nodes should be collapsed
|
|
773
|
+
// but this node should be expanded if it is in the map
|
|
774
|
+
deepMap.has(nodePath);
|
|
775
|
+
node.expanded = shouldBeExpanded;
|
|
776
|
+
}
|
|
777
|
+
});
|
|
778
|
+
this.gridApi.onGroupExpandedOrCollapsed();
|
|
778
779
|
}
|
|
779
780
|
}
|
|
780
781
|
computeColumnStateForPivotLayout(layout) {
|
|
@@ -981,7 +982,7 @@ export class LayoutManager extends LMEmitter {
|
|
|
981
982
|
this.gridApi.autoSizeColumns(columnIds);
|
|
982
983
|
return columnIds;
|
|
983
984
|
}
|
|
984
|
-
applyPivotLayout(layout) {
|
|
985
|
+
applyPivotLayout(layout, options) {
|
|
985
986
|
const columnState = this.computeColumnStateForPivotLayout(layout);
|
|
986
987
|
// by simply calling this.gridApi.applyColumnState(columnState)
|
|
987
988
|
// the order of aggregations is not preserved/guaranteed by ag-grid
|
|
@@ -1003,6 +1004,11 @@ export class LayoutManager extends LMEmitter {
|
|
|
1003
1004
|
this.computePivotAggregations(layout, columnState);
|
|
1004
1005
|
this.gridApi.applyColumnState(columnState);
|
|
1005
1006
|
this.applyPivotExpandLevel(layout);
|
|
1007
|
+
const hasGroupedColumns = layout.PivotGroupedColumns && layout.PivotGroupedColumns.length;
|
|
1008
|
+
// but also let's not forget to apply the row group values
|
|
1009
|
+
if (hasGroupedColumns && layout.RowGroupValues && !options?.skipApplyRowGroupsExpandedState) {
|
|
1010
|
+
this.applyRowGroupValues(layout.RowGroupValues);
|
|
1011
|
+
}
|
|
1006
1012
|
}
|
|
1007
1013
|
applyPivotExpandLevel(layout) {
|
|
1008
1014
|
const PivotExpandLevel = layout.PivotExpandLevel ?? -1;
|
|
@@ -69,7 +69,7 @@ export function simplifyPivotLayoutModel(layout) {
|
|
|
69
69
|
if (layout.ColumnSorts && !layout.ColumnSorts.length) {
|
|
70
70
|
delete layout.ColumnSorts;
|
|
71
71
|
}
|
|
72
|
-
if (!layout.
|
|
72
|
+
if (!layout.PivotGroupedColumns && layout.RowGroupValues) {
|
|
73
73
|
delete layout.RowGroupValues;
|
|
74
74
|
}
|
|
75
75
|
return layout;
|