Skip to content

Commit a830884

Browse files
MKirovaMKirova
authored andcommitted
fix(IgxGrid): Don't use spread operator for large collections.
1 parent bb28024 commit a830884

File tree

2 files changed

+28
-2
lines changed

2 files changed

+28
-2
lines changed

projects/igniteui-angular/src/lib/grids/common/strategy.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -127,8 +127,8 @@ export class IgxSorting implements IGridSortingStrategy {
127127
fullResult.data.push(groupItem);
128128
}
129129
if (expanded) {
130-
metadata.push(...fullResult.metadata.slice(fullResult.metadata.length - group.length));
131-
result.push(...fullResult.data.slice(fullResult.data.length - group.length));
130+
metadata = metadata.concat(fullResult.metadata.slice(fullResult.metadata.length - group.length));
131+
result = result.concat(fullResult.data.slice(fullResult.data.length - group.length));
132132
}
133133
}
134134
i += group.length;

projects/igniteui-angular/src/lib/grids/grid/grid.groupby.spec.ts

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3822,6 +3822,32 @@ describe('IgxGrid - GroupBy #grid', () => {
38223822
}
38233823
});
38243824

3825+
it('should be able to build groups with 100 000+ records', () => {
3826+
const fix = TestBed.createComponent(GroupableGridComponent);
3827+
const grid = fix.componentInstance.instance;
3828+
3829+
const data = [];
3830+
for (let i = 0; i < 1000000; i++) {
3831+
data.push({
3832+
Downloads: i,
3833+
ID: 1,
3834+
ProductName: 'Test'
3835+
});
3836+
}
3837+
3838+
fix.componentInstance.data = data;
3839+
fix.detectChanges();
3840+
3841+
grid.groupBy({
3842+
fieldName: 'ProductName',
3843+
dir: SortingDirection.Asc
3844+
});
3845+
fix.detectChanges();
3846+
3847+
let groupRows = grid.groupsRowList.toArray();
3848+
checkGroups(groupRows, ['Test']);
3849+
});
3850+
38253851
describe('GroupBy with state directive', () => {
38263852
let fix: ComponentFixture<GridGroupByStateComponent>;
38273853
let state: IgxGridStateDirective;

0 commit comments

Comments
 (0)