Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions projects/igniteui-angular/src/lib/grids/grid/column-group.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,21 @@ describe('IgxGrid - multi-column headers #grid', () => {
expect(grid.columnList.length).toEqual(10);
});

it('There shouldn\'t be any errors when the grid is grouped by a column that isn\'t defined', () => {
fixture = TestBed.createComponent(ColumnGroupTestComponent);
fixture.componentInstance.hideGroupedColumns = true;
fixture.detectChanges();
grid = fixture.componentInstance.grid;

expect(() => {
grid.groupBy({
fieldName: 'NonExistentFieldName', dir: SortingDirection.Desc, ignoreCase: false,
strategy: DefaultSortingStrategy.instance()
});
fixture.detectChanges();
}).not.toThrow();
});

it('should set title attribute on column group header spans', () => {
fixture = TestBed.createComponent(ColumnGroupTestComponent);
fixture.detectChanges();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -979,7 +979,9 @@ export class IgxGridComponent extends IgxGridBaseDirective implements GridType,
if (changes && this.columnList.length > 0) {
changes.forEachAddedItem((rec) => {
const col = this.getColumnByName(rec.item.fieldName);
col.hidden = true;
if (col) {
col.hidden = true;
}
});
changes.forEachRemovedItem((rec) => {
const col = this.getColumnByName(rec.item.fieldName);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,6 @@ export class IgxGroupByMetaPipe implements PipeTransform {

public transform(key: string, grid: GridType) {
const column = grid.getColumnByName(key);
return { groupable: column.groupable, title: column.header || key };
return { groupable: !!column?.groupable, title: column?.header || key };
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ export class OneGroupThreeColsGridComponent {

@Component({
template: `
<igx-grid #grid [data]="data" height="500px">
<igx-grid #grid [data]="data" height="500px" [hideGroupedColumns]="hideGroupedColumns">
<igx-column field="ID"></igx-column>
<igx-column-group header="General Information">
<igx-column [filterable]="true" [sortable]="true" [resizable]="true" field="CompanyName"></igx-column>
Expand Down Expand Up @@ -82,6 +82,8 @@ export class ColumnGroupTestComponent {
public emptyColGroup: IgxColumnGroupComponent;

public data = SampleTestData.contactInfoDataFull();

public hideGroupedColumns = false;
}

@Component({
Expand Down