@@ -38,6 +38,7 @@ export class PivotRowDimensionsStrategy implements IPivotDimensionStrategy {
38
38
let data ;
39
39
const prevRowDims = [ ] ;
40
40
let prevDim ;
41
+ let prevDimTopRecords = [ ] ;
41
42
const currRows = cloneArray ( rows , true ) ;
42
43
PivotUtil . assignLevels ( currRows ) ;
43
44
for ( const row of currRows ) {
@@ -48,8 +49,10 @@ export class PivotRowDimensionsStrategy implements IPivotDimensionStrategy {
48
49
data = PivotUtil . processHierarchy ( hierarchies , collection [ 0 ] ?? [ ] , pivotKeys , 0 , true ) ;
49
50
prevRowDims . push ( row ) ;
50
51
prevDim = row ;
52
+ prevDimTopRecords = data ;
51
53
} else {
52
54
const newData = [ ...data ] ;
55
+ const curDimTopRecords = [ ] ;
53
56
for ( let i = 0 ; i < newData . length ; i ++ ) {
54
57
const currData = newData [ i ] [ prevDim . memberName + '_' + pivotKeys . records ] ;
55
58
const leafData = PivotUtil . getDirectLeafs ( currData , pivotKeys ) ;
@@ -60,15 +63,22 @@ export class PivotRowDimensionsStrategy implements IPivotDimensionStrategy {
60
63
PivotUtil . processSiblingProperties ( newData [ i ] , siblingData , pivotKeys ) ;
61
64
62
65
PivotUtil . processSubGroups ( row , prevRowDims . slice ( 0 ) , siblingData , pivotKeys ) ;
63
- if ( PivotUtil . getDimensionDepth ( prevDim ) > PivotUtil . getDimensionDepth ( row ) && siblingData . length > 1 ) {
66
+ if ( ( prevDimTopRecords [ i ] . length != undefined && prevDimTopRecords [ i ] . length < siblingData . length ) || prevDimTopRecords . length <= siblingData . length ) {
64
67
newData [ i ] [ row . memberName + '_' + pivotKeys . records ] = siblingData ;
65
68
} else {
66
69
newData . splice ( i , 1 , ...siblingData ) ;
70
+ if ( prevDimTopRecords [ i ] . length == undefined ) {
71
+ prevDimTopRecords . splice ( siblingData . length , prevDimTopRecords . length - siblingData . length , ...prevDimTopRecords ) ;
72
+ } else {
73
+ prevDimTopRecords [ i ] . splice ( siblingData . length , prevDimTopRecords . length - siblingData . length , ...prevDimTopRecords [ i ] ) ;
74
+ }
67
75
i += siblingData . length - 1 ;
68
76
}
77
+ curDimTopRecords . push ( cloneArray ( siblingData , true ) ) ;
69
78
}
70
79
data = newData ;
71
80
prevDim = row ;
81
+ prevDimTopRecords = curDimTopRecords ;
72
82
prevRowDims . push ( row ) ;
73
83
}
74
84
}
0 commit comments