@@ -6736,6 +6736,12 @@ export abstract class IgxGridBaseDirective implements GridType,
67366736 . subscribe ( ( change : QueryList < IgxColumnComponent > ) => {
67376737 this . onColumnsChanged ( change ) ;
67386738 } ) ;
6739+
6740+ this . immediateColumns . changes
6741+ . pipe ( takeUntil ( this . destroy$ ) )
6742+ . subscribe ( ( change : QueryList < IgxColumnComponent > ) => {
6743+ this . resetColumns ( change ) ;
6744+ } ) ;
67396745 }
67406746
67416747 protected getColumnList ( ) {
@@ -6748,6 +6754,15 @@ export abstract class IgxGridBaseDirective implements GridType,
67486754 return this . _columnList ;
67496755 }
67506756
6757+ protected resetColumns ( change : QueryList < IgxColumnComponent > ) {
6758+ const diff = this . columnListDiffer . diff ( change ) ;
6759+ if ( diff ) {
6760+ delete this . _columnList ;
6761+ this . initColumns ( this . getColumnList ( ) , ( col : IgxColumnComponent ) => this . columnInit . emit ( col ) ) ;
6762+ this . resetCaches ( ) ;
6763+ }
6764+ }
6765+
67516766 private addColumnsFromQueryList ( col : IgxColumnComponent ) {
67526767 this . _columnList . push ( col ) ;
67536768 if ( col . columnGroup ) {
@@ -6813,9 +6828,6 @@ export abstract class IgxGridBaseDirective implements GridType,
68136828 let removed = false ;
68146829 let pinning = false ;
68156830 diff . forEachAddedItem ( ( record : IterableChangeRecord < IgxColumnComponent > ) => {
6816- if ( this . getColumnList ( ) . indexOf ( record . item ) === - 1 ) {
6817- return ;
6818- }
68196831 added = true ;
68206832 if ( record . item . pinned ) {
68216833 this . _pinnedColumns . push ( record . item ) ;
@@ -6825,15 +6837,11 @@ export abstract class IgxGridBaseDirective implements GridType,
68256837 }
68266838 } ) ;
68276839
6828- this . initColumns ( this . getColumnList ( ) , ( col : IgxColumnComponent ) => this . columnInit . emit ( col ) ) ;
68296840 if ( pinning ) {
68306841 this . initPinning ( ) ;
68316842 }
68326843
68336844 diff . forEachRemovedItem ( ( record : IterableChangeRecord < IgxColumnComponent | IgxColumnGroupComponent > ) => {
6834- if ( this . getColumnList ( ) . indexOf ( record . item ) === - 1 ) {
6835- return ;
6836- }
68376845 const isColumnGroup = record . item instanceof IgxColumnGroupComponent ;
68386846 if ( ! isColumnGroup ) {
68396847 // Clear Grouping
@@ -6858,7 +6866,6 @@ export abstract class IgxGridBaseDirective implements GridType,
68586866 removed = true ;
68596867 } ) ;
68606868
6861- this . resetCaches ( ) ;
68626869
68636870 if ( added || removed ) {
68646871 this . onColumnsAddedOrRemoved ( ) ;
0 commit comments