Skip to content

Commit 78708fa

Browse files
MKirovaMKirova
authored andcommitted
Prevent sorting more than once the same collection.
1 parent e87eb00 commit 78708fa

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

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

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,15 @@ export class PivotUtil {
2727
public static sort(data: any[], expressions: ISortingExpression[], sorting: IGridSortingStrategy = new IgxSorting(), pivotKeys): any[] {
2828
data.forEach(rec => {
2929
const keys = Object.keys(rec);
30+
rec.sorted = true;
3031
keys.forEach(k => {
31-
if (k.indexOf(pivotKeys.records) !== -1) {
32+
if (k.indexOf(pivotKeys.records) !== -1 && k !== pivotKeys.records) {
33+
const unsorted = rec[k].filter(x => !x.sorted);
3234
// sort all child record collections based on expression recursively.
33-
rec[k] = this.sort(rec[k], expressions, sorting, pivotKeys);
35+
rec[k] = this.sort(unsorted, expressions, sorting, pivotKeys);
3436
}
3537
});
38+
delete rec.sorted;
3639
});
3740
return DataUtil.sort(data, expressions, sorting);
3841
}

0 commit comments

Comments
 (0)