11import {
22 AfterContentInit ,
3+ AfterViewInit ,
34 ChangeDetectionStrategy ,
5+ ChangeDetectorRef ,
46 Component ,
7+ ComponentFactoryResolver ,
8+ ContentChild ,
59 ContentChildren ,
6- Input ,
7- QueryList ,
8- OnInit ,
9- Inject ,
10+ DoCheck ,
1011 ElementRef ,
11- ChangeDetectorRef ,
12- ComponentFactoryResolver ,
12+ EventEmitter ,
13+ Inject ,
14+ Input ,
15+ IterableChangeRecord ,
1316 IterableDiffers ,
14- ViewContainerRef ,
1517 NgZone ,
16- AfterViewInit ,
1718 OnChanges ,
18- Output ,
19- EventEmitter ,
20- Optional ,
2119 OnDestroy ,
22- DoCheck ,
23- IterableChangeRecord
20+ OnInit ,
21+ Optional ,
22+ Output ,
23+ QueryList ,
24+ TemplateRef ,
25+ ViewContainerRef
2426} from '@angular/core' ;
2527import { IgxHierarchicalGridComponent } from './hierarchical-grid.component' ;
2628import { IgxGridTransaction , IgxGridBaseDirective } from '../grid-base.directive' ;
@@ -29,19 +31,18 @@ import { IgxHierarchicalGridAPIService } from './hierarchical-grid-api.service';
2931import { DOCUMENT } from '@angular/common' ;
3032import { IgxFilteringService } from '../filtering/grid-filtering.service' ;
3133import { IDisplayDensityOptions , DisplayDensityToken } from '../../core/displayDensity' ;
32- import { TransactionService , Transaction , State } from '../../services/public_api' ;
3334import { IgxGridSummaryService } from '../summaries/grid-summary.service' ;
3435import { IgxHierarchicalGridBaseDirective } from './hierarchical-grid-base.directive' ;
3536import { IgxHierarchicalGridNavigationService } from './hierarchical-grid-navigation.service' ;
3637import { IgxGridSelectionService , IgxGridCRUDService } from '../selection/selection.service' ;
37-
3838import { IgxOverlayService } from '../../services/public_api' ;
3939import { takeUntil } from 'rxjs/operators' ;
4040import { IgxColumnComponent } from '../columns/column.component' ;
4141import { IgxRowIslandAPIService } from './row-island-api.service' ;
4242import { IBaseEventArgs } from '../../core/utils' ;
4343import { IgxColumnResizingService } from '../resizing/resizing.service' ;
4444import { GridType } from '../common/grid.interface' ;
45+ import { IgxGridToolbarDirective , IgxGridToolbarTemplateContext } from '../toolbar/common' ;
4546export interface IGridCreatedEventArgs extends IBaseEventArgs {
4647 owner : IgxRowIslandComponent ;
4748 parentID : any ;
@@ -53,10 +54,10 @@ export interface IGridCreatedEventArgs extends IBaseEventArgs {
5354 selector : 'igx-row-island' ,
5455 template : `` ,
5556 providers : [ IgxRowIslandAPIService ,
56- IgxGridSelectionService ]
57+ IgxGridSelectionService ]
5758} )
5859export class IgxRowIslandComponent extends IgxHierarchicalGridBaseDirective
59- implements AfterContentInit , AfterViewInit , OnChanges , OnInit , OnDestroy , DoCheck {
60+ implements AfterContentInit , AfterViewInit , OnChanges , OnInit , OnDestroy , DoCheck {
6061 /**
6162 * Sets the key of the row island by which child data would be taken from the row data if such is provided.
6263 * ```html
@@ -84,7 +85,7 @@ export class IgxRowIslandComponent extends IgxHierarchicalGridBaseDirective
8485 */
8586 @Input ( )
8687 set expandChildren ( value : boolean ) {
87- this . _defaultExpandState = value ;
88+ this . _defaultExpandState = value ;
8889 this . rowIslandAPI . getChildGrids ( ) . forEach ( ( grid ) => {
8990 if ( document . body . contains ( grid . nativeElement ) ) {
9091 // Detect changes right away if the grid is visible
@@ -120,6 +121,9 @@ export class IgxRowIslandComponent extends IgxHierarchicalGridBaseDirective
120121 @ContentChildren ( IgxColumnComponent , { read : IgxColumnComponent , descendants : false } )
121122 public childColumns = new QueryList < IgxColumnComponent > ( ) ;
122123
124+ @ContentChild ( IgxGridToolbarDirective , { read : TemplateRef } )
125+ public islandToolbarTemplate : TemplateRef < IgxGridToolbarTemplateContext > ;
126+
123127 /**
124128 * @hidden
125129 */
@@ -160,14 +164,14 @@ export class IgxRowIslandComponent extends IgxHierarchicalGridBaseDirective
160164 */
161165 get id ( ) {
162166 const pId = this . parentId ? this . parentId . substring ( this . parentId . indexOf ( this . layout_id ) + this . layout_id . length ) + '-' : '' ;
163- return this . layout_id + pId + this . key ;
167+ return this . layout_id + pId + this . key ;
164168 }
165169
166170 /**
167171 * @hidden
168172 */
169173 get parentId ( ) {
170- return this . parentIsland ? this . parentIsland . id : null ;
174+ return this . parentIsland ? this . parentIsland . id : null ;
171175 }
172176
173177 /**
@@ -259,16 +263,20 @@ export class IgxRowIslandComponent extends IgxHierarchicalGridBaseDirective
259263 * @hidden
260264 */
261265 ngAfterContentInit ( ) {
266+ // TODO: Discuss should it always take the parent toolbar if present
267+ this . onGridCreated . pipe ( takeUntil ( this . destroy$ ) ) . subscribe ( e => {
268+ e . grid . toolbarTemplate = this . islandToolbarTemplate || e . grid . parent . toolbarTemplate ;
269+ } ) ;
262270 this . updateChildren ( ) ;
263271 this . children . notifyOnChanges ( ) ;
264272 this . children . changes . pipe ( takeUntil ( this . destroy$ ) )
265- . subscribe ( ( change ) => {
266- this . updateChildren ( ) ;
267- // update existing grids since their child ri have been changed.
268- this . getGridsForIsland ( this . key ) . forEach ( grid => {
269- ( grid as any ) . onRowIslandChange ( this . children ) ;
273+ . subscribe ( ( change ) => {
274+ this . updateChildren ( ) ;
275+ // update existing grids since their child ri have been changed.
276+ this . getGridsForIsland ( this . key ) . forEach ( grid => {
277+ ( grid as any ) . onRowIslandChange ( this . children ) ;
278+ } ) ;
270279 } ) ;
271- } ) ;
272280 const nestedColumns = this . children . map ( ( layout ) => layout . columnList . toArray ( ) ) ;
273281 const colsArray = [ ] . concat . apply ( [ ] , nestedColumns ) ;
274282 const topCols = this . columnList . filter ( ( item ) => {
@@ -279,19 +287,19 @@ export class IgxRowIslandComponent extends IgxHierarchicalGridBaseDirective
279287 Promise . resolve ( ) . then ( ( ) => {
280288 this . updateColumnList ( ) ;
281289 } ) ;
282- } ) ;
290+ } ) ;
283291
284- // handle column changes so that they are passed to child grid instances when onColumnChange is emitted.
285- this . ri_columnListDiffer . diff ( this . childColumns ) ;
286- this . childColumns . toArray ( ) . forEach ( x => x . onColumnChange . pipe ( takeUntil ( x . destroy$ ) ) . subscribe ( ( ) => this . updateColumnList ( ) ) ) ;
287- this . childColumns . changes . pipe ( takeUntil ( this . destroy$ ) ) . subscribe ( ( change : QueryList < IgxColumnComponent > ) => {
292+ // handle column changes so that they are passed to child grid instances when onColumnChange is emitted.
293+ this . ri_columnListDiffer . diff ( this . childColumns ) ;
294+ this . childColumns . toArray ( ) . forEach ( x => x . onColumnChange . pipe ( takeUntil ( x . destroy$ ) ) . subscribe ( ( ) => this . updateColumnList ( ) ) ) ;
295+ this . childColumns . changes . pipe ( takeUntil ( this . destroy$ ) ) . subscribe ( ( change : QueryList < IgxColumnComponent > ) => {
288296 const diff = this . ri_columnListDiffer . diff ( change ) ;
289297 if ( diff ) {
290298 diff . forEachAddedItem ( ( record : IterableChangeRecord < IgxColumnComponent > ) => {
291299 record . item . onColumnChange . pipe ( takeUntil ( record . item . destroy$ ) ) . subscribe ( ( ) => this . updateColumnList ( ) ) ;
292300 } ) ;
293301 }
294- } ) ;
302+ } ) ;
295303 }
296304
297305 protected updateChildren ( ) {
@@ -358,12 +366,12 @@ export class IgxRowIslandComponent extends IgxHierarchicalGridBaseDirective
358366 /**
359367 * @hidden
360368 */
361- reflow ( ) { }
369+ reflow ( ) { }
362370
363371 /**
364372 * @hidden
365373 */
366- calculateGridHeight ( ) { }
374+ calculateGridHeight ( ) { }
367375
368376 protected updateColumnList ( ) {
369377 const nestedColumns = this . children . map ( ( layout ) => layout . columnList . toArray ( ) ) ;
0 commit comments