Skip to content

Commit e91e1f5

Browse files
authored
Merge pull request #6161 from IgniteUI/nrobakova/fix-issue-6134-81
Fix error when delete child column from a column group
2 parents 3f18698 + 9506ef2 commit e91e1f5

File tree

2 files changed

+15
-7
lines changed

2 files changed

+15
-7
lines changed

projects/igniteui-angular/src/lib/grids/column.component.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1852,7 +1852,7 @@ export class IgxColumnGroupComponent extends IgxColumnComponent implements After
18521852
*/
18531853
this.children.changes.pipe(takeUntil(this.destroy$))
18541854
.subscribe((change) => {
1855-
if (change.length > 1 && change.first === this) {
1855+
if (change.first === this) {
18561856
this.children.reset(this.children.toArray().slice(1));
18571857
this.children.forEach(child => {
18581858
child.parent = this;

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

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1469,21 +1469,29 @@ describe('IgxGrid - multi-column headers', () => {
14691469

14701470
expect(grid.columnList.length).toEqual(9);
14711471

1472+
expect(() => {
1473+
// Delete all column
1474+
fixture.componentInstance.columnGroups[0].columns.splice(0, 2);
1475+
fixture.detectChanges();
1476+
}).not.toThrow();
1477+
1478+
expect(grid.columnList.length).toEqual(7);
1479+
14721480
expect(() => {
14731481
// Add column
14741482
fixture.componentInstance.columnGroups[0].columns.push({ field: 'Fax', type: 'string' });
14751483
fixture.detectChanges();
14761484
}).not.toThrow();
14771485

1478-
expect(grid.columnList.length).toEqual(10);
1486+
expect(grid.columnList.length).toEqual(8);
14791487

14801488
expect(() => {
14811489
// Update column
1482-
fixture.componentInstance.columnGroups[0].columns[1] = { field: 'City', type: 'string' };
1490+
fixture.componentInstance.columnGroups[0].columns[0] = { field: 'City', type: 'string' };
14831491
fixture.detectChanges();
14841492
}).not.toThrow();
14851493

1486-
expect(grid.columnList.length).toEqual(10);
1494+
expect(grid.columnList.length).toEqual(8);
14871495
});
14881496
});
14891497

@@ -1864,15 +1872,15 @@ export class DynamicColGroupsGridComponent {
18641872
{ columnHeader: 'First', columns: [
18651873
{ field: 'ID', type: 'string' },
18661874
{ field: 'CompanyName', type: 'string' },
1867-
{ field: 'ContactName', type: 'string' },
1875+
{ field: 'ContactName', type: 'string' }
18681876
]},
18691877
{ columnHeader: 'Second', columns: [
18701878
{ field: 'ContactTitle', type: 'string' },
1871-
{ field: 'Address', type: 'string' },
1879+
{ field: 'Address', type: 'string' }
18721880
]},
18731881
{ columnHeader: 'Third', columns: [
18741882
{ field: 'PostlCode', type: 'string' },
1875-
{ field: 'Contry', type: 'string' },
1883+
{ field: 'Contry', type: 'string' }
18761884
]},
18771885
];
18781886
}

0 commit comments

Comments
 (0)