|
1 | | -import { Component, ViewChild, OnInit, DebugElement, QueryList } from '@angular/core'; |
| 1 | +import { Component, ViewChild, OnInit, DebugElement, QueryList, TemplateRef } from '@angular/core'; |
2 | 2 | import { TestBed, ComponentFixture, fakeAsync, tick } from '@angular/core/testing'; |
3 | 3 | import { configureTestSuite } from '../../test-utils/configure-suite'; |
4 | 4 | import { NoopAnimationsModule } from '@angular/platform-browser/animations'; |
@@ -346,6 +346,17 @@ describe('IgxGrid Master Detail #grid', () => { |
346 | 346 | expect(row.expanded).toBeFalsy(); |
347 | 347 | }); |
348 | 348 | }); |
| 349 | + |
| 350 | + it('should allow setting external details template via Input.', () => { |
| 351 | + grid = fix.componentInstance.grid; |
| 352 | + grid.detailTemplate = fix.componentInstance.detailTemplate; |
| 353 | + fix.detectChanges(); |
| 354 | + grid.toggleRow(fix.componentInstance.data[0].ID); |
| 355 | + fix.detectChanges(); |
| 356 | + const gridRows = grid.rowList.toArray(); |
| 357 | + const firstDetail = GridFunctions.getMasterRowDetail(gridRows[0]); |
| 358 | + expect(firstDetail.textContent.trim()).toBe('NEW TEMPLATE'); |
| 359 | + }); |
349 | 360 | }); |
350 | 361 |
|
351 | 362 | describe('Keyboard Navigation ', () => { |
@@ -1257,12 +1268,20 @@ describe('IgxGrid Master Detail #grid', () => { |
1257 | 1268 | </div> |
1258 | 1269 | </ng-template> |
1259 | 1270 | </igx-grid> |
| 1271 | + <ng-template igxGridDetail let-dataItem #detailTemplate> |
| 1272 | + <div> |
| 1273 | + NEW TEMPLATE |
| 1274 | + </div> |
| 1275 | + </ng-template> |
1260 | 1276 | ` |
1261 | 1277 | }) |
1262 | 1278 | export class DefaultGridMasterDetailComponent { |
1263 | 1279 | @ViewChild(IgxGridComponent, { read: IgxGridComponent, static: true }) |
1264 | 1280 | public grid: IgxGridComponent; |
1265 | 1281 |
|
| 1282 | + @ViewChild('detailTemplate', { read: TemplateRef, static: true }) |
| 1283 | + public detailTemplate: TemplateRef<any>; |
| 1284 | + |
1266 | 1285 | public width = '800px'; |
1267 | 1286 | public height = '500px'; |
1268 | 1287 | public data = SampleTestData.contactInfoDataFull(); |
|
0 commit comments