Skip to content

Commit 35f667a

Browse files
authored
Merge pull request #5862 from IgniteUI/mkirova/fix-5204-master
fix(igxHierarchicalGrid): Init pinning states after columns are creat…
2 parents 6c348ca + 89aa9a5 commit 35f667a

File tree

2 files changed

+30
-0
lines changed

2 files changed

+30
-0
lines changed

projects/igniteui-angular/src/lib/grids/hierarchical-grid/hierarchical-grid-base.component.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,7 @@ export abstract class IgxHierarchicalGridBaseComponent extends IgxGridBaseCompon
168168
const result = flatten(columns);
169169
this.columnList.reset(result);
170170
this.columnList.notifyOnChanges();
171+
this.initPinning();
171172
}
172173

173174
protected _createColumn(col) {

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

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -937,6 +937,35 @@ describe('IgxHierarchicalGrid Integration #hGrid', () => {
937937
expect(childGrid.columnList.toArray()[0].pinned).toBeTruthy();
938938
expect(headers[0].classList.contains('igx-grid__th--pinned')).toBeTruthy();
939939
}));
940+
941+
it('should be applied correctly for child grid with multi-column header.', (() => {
942+
const ri = fixture.componentInstance.rowIsland;
943+
const col = ri.columnList.find(x => x.header === 'Information');
944+
col.pinned = true;
945+
fixture.detectChanges();
946+
947+
const row = hierarchicalGrid.getRowByIndex(0) as IgxHierarchicalRowComponent;
948+
UIInteractions.clickElement(row.expander);
949+
fixture.detectChanges();
950+
951+
const childGrids = fixture.debugElement.queryAll(By.css('igx-child-grid-row'));
952+
const childGrid = childGrids[0].query(By.css('igx-hierarchical-grid')).componentInstance;
953+
// check unpinned/pinned columns
954+
expect(childGrid.pinnedColumns.length).toBe(3);
955+
expect(childGrid.unpinnedColumns.length).toBe(1);
956+
// check cells
957+
const cells = childGrid.getRowByIndex(0).cells;
958+
expect(cells.length).toBe(3);
959+
let cell = childGrid.getCellByColumn(0, 'ChildLevels');
960+
expect(cell.visibleColumnIndex).toEqual(0);
961+
expect(cell.nativeElement.classList.contains('igx-grid__td--pinned')).toBe(true);
962+
cell = childGrid.getCellByColumn(0, 'ProductName');
963+
expect(cell.visibleColumnIndex).toEqual(1);
964+
expect(cell.nativeElement.classList.contains('igx-grid__td--pinned')).toBe(true);
965+
cell = childGrid.getCellByColumn(0, 'ID');
966+
expect(cell.visibleColumnIndex).toEqual(2);
967+
expect(cell.nativeElement.classList.contains('igx-grid__td--pinned')).toBe(false);
968+
}));
940969
});
941970
});
942971

0 commit comments

Comments
 (0)