11import {
22 booleanAttribute ,
3+ ComponentRef ,
34 createComponent ,
45 Directive ,
56 EventEmitter ,
@@ -132,6 +133,8 @@ export abstract class IgxHierarchicalGridBaseDirective extends IgxGridBaseDirect
132133 /* blazorSuppress */
133134 public abstract expandChildren : boolean ;
134135
136+ protected _rowIslandColumnRefs : ComponentRef < IgxColumnComponent > [ ] = [ ] ;
137+
135138 /**
136139 * @hidden
137140 */
@@ -141,6 +144,7 @@ export abstract class IgxHierarchicalGridBaseDirective extends IgxGridBaseDirect
141144 topLevelCols . forEach ( ( col ) => {
142145 col . grid = this ;
143146 const ref = this . _createColumn ( col ) ;
147+ this . _rowIslandColumnRefs . push ( ref ) ;
144148 ref . changeDetectorRef . detectChanges ( ) ;
145149 columns . push ( ref . instance ) ;
146150 } ) ;
@@ -189,7 +193,9 @@ export abstract class IgxHierarchicalGridBaseDirective extends IgxGridBaseDirect
189193 if ( col . children . length > 0 ) {
190194 const newChildren = [ ] ;
191195 col . children . forEach ( child => {
192- const newCol = this . _createColumn ( child ) . instance ;
196+ const childRef = this . _createColumn ( child ) ;
197+ this . _rowIslandColumnRefs . push ( childRef ) ;
198+ const newCol = childRef . instance ;
193199 newCol . parent = ref . instance ;
194200 newChildren . push ( newCol ) ;
195201 } ) ;
@@ -214,6 +220,16 @@ export abstract class IgxHierarchicalGridBaseDirective extends IgxGridBaseDirect
214220 return ref ;
215221 }
216222
223+ public override ngOnDestroy ( ) {
224+ this . destroyRowIslandColumnRefs ( ) ;
225+ super . ngOnDestroy ( ) ;
226+ }
227+
228+ protected destroyRowIslandColumnRefs ( ) {
229+ this . _rowIslandColumnRefs . forEach ( ref => ref . destroy ( ) ) ;
230+ this . _rowIslandColumnRefs = [ ] ;
231+ }
232+
217233 protected getGridsForIsland ( rowIslandID : string ) {
218234 return this . gridAPI . getChildGridsForRowIsland ( rowIslandID ) ;
219235 }
0 commit comments