@@ -906,6 +906,30 @@ describe('IgxHierarchicalGrid Template Changing Scenarios', () => {
906906 expect ( child2Headers [ 2 ] . nativeElement . innerText ) . toEqual ( 'Col1' ) ;
907907 } ) ;
908908
909+ it ( 'should render correct columns when setting columns for parent and child post init using ngFor' , ( ) => {
910+ const row = hierarchicalGrid . getRowByIndex ( 0 ) as IgxHierarchicalRowComponent ;
911+ UIInteractions . clickElement ( row . expander ) ;
912+ fixture . detectChanges ( ) ;
913+
914+ const child1Grids = fixture . debugElement . queryAll ( By . css ( 'igx-child-grid-row' ) ) ;
915+ const child1Grid = child1Grids [ 0 ] . query ( By . css ( 'igx-hierarchical-grid' ) ) . componentInstance ;
916+
917+ fixture . componentInstance . parentCols = [ 'Col1' , 'Col2' ] ;
918+ fixture . componentInstance . islandCols1 = [ 'ID' , 'ProductName' , 'Col1' ] ;
919+ fixture . detectChanges ( ) ;
920+ // check parent cols
921+ expect ( hierarchicalGrid . columns . length ) . toBe ( 4 ) ;
922+ expect ( hierarchicalGrid . columns [ 0 ] . field ) . toBe ( 'ID' ) ;
923+ expect ( hierarchicalGrid . columns [ 1 ] . field ) . toBe ( 'ProductName' ) ;
924+ expect ( hierarchicalGrid . columns [ 2 ] . field ) . toBe ( 'Col1' ) ;
925+ expect ( hierarchicalGrid . columns [ 3 ] . field ) . toBe ( 'Col2' ) ;
926+ // check child cols
927+ expect ( child1Grid . columns . length ) . toBe ( 3 ) ;
928+ expect ( hierarchicalGrid . columns [ 0 ] . field ) . toBe ( 'ID' ) ;
929+ expect ( hierarchicalGrid . columns [ 1 ] . field ) . toBe ( 'ProductName' ) ;
930+ expect ( hierarchicalGrid . columns [ 2 ] . field ) . toBe ( 'Col1' ) ;
931+ } ) ;
932+
909933 it ( 'should update columns for expanded child when adding column to row island' , ( ) => {
910934 const row = hierarchicalGrid . getRowByIndex ( 0 ) as IgxHierarchicalRowComponent ;
911935 UIInteractions . clickElement ( row . expander ) ;
@@ -1210,6 +1234,7 @@ export class IgxHGridRemoteOnDemandComponent {
12101234 <igx-hierarchical-grid #hierarchicalGrid [data]="data" [autoGenerate]="false" [height]="'500px'" [width]="'800px'" >
12111235 <igx-column field="ID"></igx-column>
12121236 <igx-column field="ProductName"></igx-column>
1237+ <igx-column *ngFor="let colField of parentCols" [field]="colField"></igx-column>
12131238 <igx-row-island [key]="'childData'" [autoGenerate]="false" #rowIsland [height]="'350px'">
12141239 <igx-column *ngFor="let colField of islandCols1" [field]="colField"></igx-column>
12151240 <igx-row-island [key]="'childData'" [autoGenerate]="false" #rowIsland2 [height]="'200px'">
@@ -1221,6 +1246,7 @@ export class IgxHGridRemoteOnDemandComponent {
12211246export class IgxHierarchicalGridColumnsUpdateComponent extends IgxHierarchicalGridTestBaseComponent implements AfterViewInit {
12221247 public cols1 = [ 'ID' , 'ProductName' , 'Col1' , 'Col2' , 'Col3' ] ;
12231248 public cols2 = [ 'ID' , 'ProductName' , 'Col1' ] ;
1249+ public parentCols = [ ] ;
12241250 public islandCols1 = [ ] ;
12251251 public islandCols2 = [ ] ;
12261252 constructor ( public cdr : ChangeDetectorRef ) {
0 commit comments