Skip to content

Commit 827b1ff

Browse files
authored
Merge pull request #5861 from IgniteUI/mkirova/fix-5204-8.1.x
fix(igxHierarchicalGrid): Init pinning states after columns are creat…
2 parents b8e81ae + 345a325 commit 827b1ff

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
@@ -163,6 +163,7 @@ export abstract class IgxHierarchicalGridBaseComponent extends IgxGridBaseCompon
163163
const result = flatten(columns);
164164
this.columnList.reset(result);
165165
this.columnList.notifyOnChanges();
166+
this.initPinning();
166167
}
167168

168169
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
@@ -942,6 +942,35 @@ describe('IgxHierarchicalGrid Integration', () => {
942942
expect(childGrid.columnList.toArray()[0].pinned).toBeTruthy();
943943
expect(headers[0].classList.contains('igx-grid__th--pinned')).toBeTruthy();
944944
}));
945+
946+
it('should be applied correctly for child grid with multi-column header.', (() => {
947+
const ri = fixture.componentInstance.rowIsland;
948+
const col = ri.columnList.find(x => x.header === 'Information');
949+
col.pinned = true;
950+
fixture.detectChanges();
951+
952+
const row = hierarchicalGrid.getRowByIndex(0) as IgxHierarchicalRowComponent;
953+
UIInteractions.clickElement(row.expander);
954+
fixture.detectChanges();
955+
956+
const childGrids = fixture.debugElement.queryAll(By.css('igx-child-grid-row'));
957+
const childGrid = childGrids[0].query(By.css('igx-hierarchical-grid')).componentInstance;
958+
// check unpinned/pinned columns
959+
expect(childGrid.pinnedColumns.length).toBe(3);
960+
expect(childGrid.unpinnedColumns.length).toBe(1);
961+
// check cells
962+
const cells = childGrid.getRowByIndex(0).cells;
963+
expect(cells.length).toBe(3);
964+
let cell = childGrid.getCellByColumn(0, 'ChildLevels');
965+
expect(cell.visibleColumnIndex).toEqual(0);
966+
expect(cell.nativeElement.classList.contains('igx-grid__td--pinned')).toBe(true);
967+
cell = childGrid.getCellByColumn(0, 'ProductName');
968+
expect(cell.visibleColumnIndex).toEqual(1);
969+
expect(cell.nativeElement.classList.contains('igx-grid__td--pinned')).toBe(true);
970+
cell = childGrid.getCellByColumn(0, 'ID');
971+
expect(cell.visibleColumnIndex).toEqual(2);
972+
expect(cell.nativeElement.classList.contains('igx-grid__td--pinned')).toBe(false);
973+
}));
945974
});
946975
});
947976

0 commit comments

Comments
 (0)