@@ -5,7 +5,7 @@ import { PivotUtil } from '../grids/pivot-grid/pivot-util';
5
5
import { FilteringStrategy } from './filtering-strategy' ;
6
6
import { GridColumnDataType } from './data-util' ;
7
7
import { DefaultSortingStrategy , SortingDirection } from './sorting-strategy' ;
8
- import { parseDate } from '../core/utils' ;
8
+ import { cloneArray , parseDate } from '../core/utils' ;
9
9
10
10
export class NoopPivotDimensionsStrategy implements IPivotDimensionStrategy {
11
11
private static _instance : NoopPivotDimensionsStrategy = null ;
@@ -28,33 +28,35 @@ export class PivotRowDimensionsStrategy implements IPivotDimensionStrategy {
28
28
}
29
29
30
30
public process (
31
- collection : any ,
32
- rows : IPivotDimension [ ] ,
33
- values ?: IPivotValue [ ] ,
34
- pivotKeys : IPivotKeys =
35
- { aggregations : 'aggregations' , records : 'records' , children : 'children' , level : 'level' }
36
- ) : any [ ] {
37
- let hierarchies ;
38
- let data ;
39
- const prevRowDims = [ ] ;
40
- let prevDim ;
41
- for ( const row of rows ) {
42
- if ( ! data ) {
43
- // build hierarchies - groups and subgroups
44
- hierarchies = PivotUtil . getFieldsHierarchy ( collection , [ row ] , PivotDimensionType . Row , pivotKeys ) ;
45
- // generate flat data from the hierarchies
46
- data = PivotUtil . processHierarchy ( hierarchies , collection [ 0 ] ?? [ ] , pivotKeys , 0 , true ) ;
47
- prevRowDims . push ( row ) ;
48
- prevDim = row ;
49
- } else {
50
- const newData = [ ...data ] ;
51
- for ( let i = 0 ; i < newData . length ; i ++ ) {
52
- const currData = newData [ i ] [ prevDim . memberName + '_' + pivotKeys . records ] ;
53
- const hierarchyFields = PivotUtil
54
- . getFieldsHierarchy ( currData , [ row ] , PivotDimensionType . Row , pivotKeys ) ;
55
- const siblingData = PivotUtil
56
- . processHierarchy ( hierarchyFields , newData [ i ] ?? [ ] , pivotKeys , 0 ) ;
57
- PivotUtil . processSiblingProperties ( newData [ i ] , siblingData , pivotKeys ) ;
31
+ collection : any ,
32
+ rows : IPivotDimension [ ] ,
33
+ values ?: IPivotValue [ ] ,
34
+ pivotKeys : IPivotKeys =
35
+ { aggregations : 'aggregations' , records : 'records' , children : 'children' , level : 'level' }
36
+ ) : any [ ] {
37
+ let hierarchies ;
38
+ let data ;
39
+ const prevRowDims = [ ] ;
40
+ let prevDim ;
41
+ const currRows = cloneArray ( rows , true ) ;
42
+ PivotUtil . assignLevels ( currRows ) ;
43
+ for ( const row of currRows ) {
44
+ if ( ! data ) {
45
+ // build hierarchies - groups and subgroups
46
+ hierarchies = PivotUtil . getFieldsHierarchy ( collection , [ row ] , PivotDimensionType . Row , pivotKeys ) ;
47
+ // generate flat data from the hierarchies
48
+ data = PivotUtil . processHierarchy ( hierarchies , collection [ 0 ] ?? [ ] , pivotKeys , 0 , true ) ;
49
+ prevRowDims . push ( row ) ;
50
+ prevDim = row ;
51
+ } else {
52
+ const newData = [ ...data ] ;
53
+ for ( let i = 0 ; i < newData . length ; i ++ ) {
54
+ const currData = newData [ i ] [ prevDim . memberName + '_' + pivotKeys . records ] ;
55
+ const hierarchyFields = PivotUtil
56
+ . getFieldsHierarchy ( currData , [ row ] , PivotDimensionType . Row , pivotKeys ) ;
57
+ const siblingData = PivotUtil
58
+ . processHierarchy ( hierarchyFields , newData [ i ] ?? [ ] , pivotKeys , 0 ) ;
59
+ PivotUtil . processSiblingProperties ( newData [ i ] , siblingData , pivotKeys ) ;
58
60
59
61
PivotUtil . processSubGroups ( row , prevRowDims . slice ( 0 ) , siblingData , pivotKeys ) ;
60
62
if ( siblingData . length > 1 ) {
0 commit comments