Skip to content

Commit 7f261ec

Browse files
MKirovaMKirova
authored andcommitted
Clean hierarchy after flattening. Ensure pipes are re-triggered on sort change.
1 parent 1dca5eb commit 7f261ec

File tree

2 files changed

+22
-7
lines changed

2 files changed

+22
-7
lines changed

projects/igniteui-angular/src/lib/grids/pivot-grid/pivot-grid.component.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,9 @@
3232
class="igx-grid__scroll-on-drag-pinned" [style.left.px]="pinnedWidth"></span>
3333
<ng-template igxGridFor let-rowData [igxGridForOf]="data
3434
| pivotGridFilter:pivotConfiguration:filterStrategy:advancedFilteringExpressionsTree
35-
| pivotGridRow:pivotConfiguration:expansionStates:pipeTrigger
36-
| pivotGridColumn:pivotConfiguration:expansionStates:pipeTrigger
37-
| pivotGridColumnSort:sortingExpressions:sortStrategy:id:pipeTrigger:true
35+
| pivotGridRow:pivotConfiguration:expansionStates:pipeTrigger:sortingExpressions
36+
| pivotGridColumn:pivotConfiguration:expansionStates:pipeTrigger:sortingExpressions
37+
| pivotGridColumnSort:sortingExpressions:sortStrategy:pipeTrigger:sortingExpressions
3838
| pivotGridRowExpansion:pivotConfiguration:expansionStates:pipeTrigger"
3939
let-rowIndex="index" [igxForScrollOrientation]="'vertical'" [igxForScrollContainer]='verticalScroll'
4040
[igxForContainerSize]='calcHeight'

projects/igniteui-angular/src/lib/grids/pivot-grid/pivot-grid.pipes.ts

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ export class IgxPivotRowPipe implements PipeTransform {
2525
config: IPivotConfiguration,
2626
_: Map<any, boolean>,
2727
_pipeTrigger?: number,
28+
__?,
2829
pivotKeys: IPivotKeys = {aggregations: 'aggregations', records: 'records', children: 'children', level: 'level'}
2930
): any[] {
3031
const enabledRows = config.rows.filter(x => x.enabled);
@@ -49,6 +50,7 @@ export class IgxPivotRowExpansionPipe implements PipeTransform {
4950
config: IPivotConfiguration,
5051
expansionStates: Map<any, boolean>,
5152
_pipeTrigger?: number,
53+
__?,
5254
pivotKeys: IPivotKeys = {aggregations: 'aggregations', records: 'records', children: 'children', level: 'level'}
5355
): any[] {
5456
const enabledRows = config.rows.filter(x => x.enabled);
@@ -61,8 +63,21 @@ export class IgxPivotRowExpansionPipe implements PipeTransform {
6163
PivotUtil.flattenHierarchy(data, config, row, expansionStates, pivotKeys, totalLlv, prevDims, 0);
6264
prevDims.push(row);
6365
}
66+
this.cleanState(data, pivotKeys);
6467
return data;
6568
}
69+
70+
private cleanState(data, pivotKeys) {
71+
data.forEach(rec => {
72+
const keys = Object.keys(rec);
73+
//remove all record keys from final data since we don't need them anymore.
74+
keys.forEach(k => {
75+
if (k.indexOf(pivotKeys.records) !== -1) {
76+
delete rec[k];
77+
}
78+
});
79+
});
80+
}
6681
}
6782

6883

@@ -80,6 +95,7 @@ export class IgxPivotColumnPipe implements PipeTransform {
8095
config: IPivotConfiguration,
8196
_: Map<any, boolean>,
8297
_pipeTrigger?: number,
98+
__?,
8399
pivotKeys: IPivotKeys = {aggregations: 'aggregations', records: 'records', children: 'children', level: 'level'}
84100
): any[] {
85101
const enabledColumns = config.columns.filter(x => x.enabled);
@@ -140,16 +156,15 @@ export class IgxPivotGridFilterPipe implements PipeTransform {
140156
})
141157
export class IgxPivotGridSortingPipe implements PipeTransform {
142158

143-
public transform(collection: any[], expressions: ISortingExpression[], sorting: IGridSortingStrategy,
144-
id: string, pipeTrigger: number, pinned?): any[] {
159+
public transform(collection: any[], expressions: ISortingExpression[], sorting: IGridSortingStrategy, pipeTrigger: number): any[] {
145160
let result: any[];
146161

147162
if (!expressions.length) {
148163
result = collection;
149164
} else {
165+
// TODO - sort recursively in all records collections.
150166
result = DataUtil.sort(cloneArray(collection), expressions, sorting);
151167
}
152-
153168
return result;
154169
}
155-
}
170+
}

0 commit comments

Comments
 (0)