1
- import { Component , ViewChild , OnInit , DebugElement , QueryList , TemplateRef } from '@angular/core' ;
1
+ import { Component , ViewChild , OnInit , DebugElement , QueryList , TemplateRef , ContentChild , ViewChildren } from '@angular/core' ;
2
2
import { TestBed , ComponentFixture , fakeAsync , tick , waitForAsync } from '@angular/core/testing' ;
3
3
import { NoopAnimationsModule } from '@angular/platform-browser/animations' ;
4
4
import { By } from '@angular/platform-browser' ;
@@ -358,6 +358,16 @@ describe('IgxGrid Master Detail #grid', () => {
358
358
const firstDetail = GridFunctions . getMasterRowDetail ( gridRows [ 0 ] ) ;
359
359
expect ( firstDetail . textContent . trim ( ) ) . toBe ( 'NEW TEMPLATE' ) ;
360
360
} ) ;
361
+
362
+ it ( 'should allow grids in details view without breaking the column collection of the master grid' , ( ) => {
363
+ grid = fix . componentInstance . grid ;
364
+ grid . detailTemplate = fix . componentInstance . gridTemplate ;
365
+ fix . detectChanges ( ) ;
366
+ grid . toggleRow ( fix . componentInstance . data [ 0 ] . ID ) ;
367
+ fix . detectChanges ( ) ;
368
+ expect ( grid . unpinnedColumns . map ( c => c . field ) ) . toEqual ( [ 'ContactName' , 'CompanyName' ] ) ;
369
+ expect ( fix . componentInstance . childGrid . first . unpinnedColumns . map ( c => c . field ) ) . toEqual ( [ 'ColA' , 'ColB' ] ) ;
370
+ } ) ;
361
371
} ) ;
362
372
363
373
describe ( 'Keyboard Navigation ' , ( ) => {
@@ -1282,6 +1292,12 @@ describe('IgxGrid Master Detail #grid', () => {
1282
1292
NEW TEMPLATE
1283
1293
</div>
1284
1294
</ng-template>
1295
+ <ng-template igxGridDetail #gridTemplate>
1296
+ <igx-grid #childGrid>
1297
+ <igx-column [field]="'ColA'" [width]="'400px'"></igx-column>
1298
+ <igx-column [field]="'ColB'" [width]="'400px'"></igx-column>
1299
+ </igx-grid>
1300
+ </ng-template>
1285
1301
` ,
1286
1302
imports : [ IgxGridComponent , IgxColumnComponent , IgxGridDetailTemplateDirective , IgxCheckboxComponent , IgxPaginatorComponent , IgxInputGroupComponent , IgxInputDirective ]
1287
1303
} )
@@ -1292,6 +1308,12 @@ export class DefaultGridMasterDetailComponent {
1292
1308
@ViewChild ( 'detailTemplate' , { read : TemplateRef , static : true } )
1293
1309
public detailTemplate : TemplateRef < any > ;
1294
1310
1311
+ @ViewChild ( 'gridTemplate' , { read : TemplateRef , static : true } )
1312
+ public gridTemplate : TemplateRef < any > ;
1313
+
1314
+ @ViewChildren ( 'childGrid' , { read : IgxGridComponent } )
1315
+ public childGrid : IgxGridComponent ;
1316
+
1295
1317
public width = '800px' ;
1296
1318
public height = '500px' ;
1297
1319
public data = SampleTestData . contactInfoDataFull ( ) ;
0 commit comments