@@ -1154,6 +1154,17 @@ export abstract class IgxGridBaseDirective implements GridType,
11541154 @ContentChildren ( IgxColumnComponent , { read : IgxColumnComponent , descendants : true } )
11551155 public columnList : QueryList < IgxColumnComponent > = new QueryList < IgxColumnComponent > ( ) ;
11561156
1157+ /* reactContentChildren */
1158+ /* blazorInclude */
1159+ /* blazorTreatAsCollection */
1160+ /* blazorCollectionName: ColumnCollection */
1161+ /* ngQueryListName: columnList */
1162+ /**
1163+ * @hidden @internal
1164+ */
1165+ @ContentChildren ( IgxColumnComponent , { read : IgxColumnComponent , descendants : false } )
1166+ private immediateColumns : QueryList < IgxColumnComponent > = new QueryList < IgxColumnComponent > ( ) ;
1167+
11571168 /* contentChildren */
11581169 /* blazorInclude */
11591170 /* blazorTreatAsCollection */
@@ -3112,7 +3123,10 @@ export abstract class IgxGridBaseDirective implements GridType,
31123123 protected _allowFiltering = false ;
31133124 protected _allowAdvancedFiltering = false ;
31143125 protected _filterMode : FilterMode = FilterMode . quickFilter ;
3115-
3126+ /**
3127+ * @hidden @internal A column list cache
3128+ */
3129+ protected _columnList : Array < IgxColumnComponent > = null ;
31163130
31173131 protected _defaultTargetRecordNumber = 10 ;
31183132 protected _expansionStates : Map < any , boolean > = new Map < any , boolean > ( ) ;
@@ -3667,24 +3681,24 @@ export abstract class IgxGridBaseDirective implements GridType,
36673681 throttleTime ( 40 , animationFrameScheduler , { leading : true , trailing : true } ) ,
36683682 destructor
36693683 )
3670- . subscribe ( ( ) => {
3671- this . zone . run ( ( ) => {
3672- // do not trigger reflow if element is detached.
3673- if ( this . nativeElement . isConnected ) {
3674- if ( this . shouldResize ) {
3675- // resizing occurs due to the change of --ig-size css var
3676- this . _gridSize = this . gridSize ;
3677- this . updateDefaultRowHeight ( ) ;
3678- this . _autoSize = this . isPercentHeight && this . calcHeight !== this . getDataBasedBodyHeight ( ) ;
3679- this . crudService . endEdit ( false ) ;
3680- if ( this . _summaryRowHeight === 0 ) {
3681- this . summaryService . summaryHeight = 0 ;
3684+ . subscribe ( ( ) => {
3685+ this . zone . run ( ( ) => {
3686+ // do not trigger reflow if element is detached.
3687+ if ( this . nativeElement . isConnected ) {
3688+ if ( this . shouldResize ) {
3689+ // resizing occurs due to the change of --ig-size css var
3690+ this . _gridSize = this . gridSize ;
3691+ this . updateDefaultRowHeight ( ) ;
3692+ this . _autoSize = this . isPercentHeight && this . calcHeight !== this . getDataBasedBodyHeight ( ) ;
3693+ this . crudService . endEdit ( false ) ;
3694+ if ( this . _summaryRowHeight === 0 ) {
3695+ this . summaryService . summaryHeight = 0 ;
3696+ }
36823697 }
3698+ this . notifyChanges ( true ) ;
36833699 }
3684- this . notifyChanges ( true ) ;
3685- }
3700+ } ) ;
36863701 } ) ;
3687- } ) ;
36883702
36893703 this . pipeTriggerNotifier . pipe ( takeUntil ( this . destroy$ ) ) . subscribe ( ( ) => this . pipeTrigger ++ ) ;
36903704 this . columnMovingEnd . pipe ( destructor ) . subscribe ( ( ) => this . crudService . endEdit ( false ) ) ;
@@ -3770,10 +3784,10 @@ export abstract class IgxGridBaseDirective implements GridType,
37703784 throttleTime ( 0 , animationFrameScheduler , { leading : false , trailing : true } ) ,
37713785 destructor
37723786 )
3773- . subscribe ( ( ) => {
3774- this . autoSizeColumnsInView ( ) ;
3775- this . _firstAutoResize = false ;
3776- } ) ;
3787+ . subscribe ( ( ) => {
3788+ this . autoSizeColumnsInView ( ) ;
3789+ this . _firstAutoResize = false ;
3790+ } ) ;
37773791 }
37783792
37793793 /**
@@ -5459,7 +5473,7 @@ export abstract class IgxGridBaseDirective implements GridType,
54595473 visibleChildColumns . length - columnsWithSetWidths . length ;
54605474 const sumExistingWidths = columnsWithSetWidths
54615475 . reduce ( ( prev , curr ) => {
5462- const colInstance = this . hasColumnLayouts ? curr . ref : curr ;
5476+ const colInstance = this . hasColumnLayouts ? curr . ref : curr ;
54635477 const colWidth = ! colInstance . widthConstrained ? curr . width : colInstance . calcPixelWidth ;
54645478 let widthValue = parseFloat ( colWidth ) ;
54655479 if ( isNaN ( widthValue ) ) {
@@ -6725,7 +6739,22 @@ export abstract class IgxGridBaseDirective implements GridType,
67256739 }
67266740
67276741 protected getColumnList ( ) {
6728- return this . columnList . toArray ( ) ;
6742+ if ( ! this . _columnList ) {
6743+ this . _columnList = [ ] ;
6744+ this . immediateColumns . toArray ( ) . forEach ( ( col ) => {
6745+ this . addColumnsFromQueryList ( col ) ;
6746+ } ) ;
6747+ }
6748+ return this . _columnList ;
6749+ }
6750+
6751+ private addColumnsFromQueryList ( col : IgxColumnComponent ) {
6752+ this . _columnList . push ( col ) ;
6753+ if ( col . columnGroup ) {
6754+ col . children . toArray ( ) . forEach ( ( child ) => {
6755+ this . addColumnsFromQueryList ( child ) ;
6756+ } ) ;
6757+ }
67296758 }
67306759
67316760 /**
@@ -6779,10 +6808,14 @@ export abstract class IgxGridBaseDirective implements GridType,
67796808 return ;
67806809 }
67816810 if ( diff ) {
6811+ delete this . _columnList ;
67826812 let added = false ;
67836813 let removed = false ;
67846814 let pinning = false ;
67856815 diff . forEachAddedItem ( ( record : IterableChangeRecord < IgxColumnComponent > ) => {
6816+ if ( this . getColumnList ( ) . indexOf ( record . item ) === - 1 ) {
6817+ return ;
6818+ }
67866819 added = true ;
67876820 if ( record . item . pinned ) {
67886821 this . _pinnedColumns . push ( record . item ) ;
@@ -6792,12 +6825,15 @@ export abstract class IgxGridBaseDirective implements GridType,
67926825 }
67936826 } ) ;
67946827
6795- this . initColumns ( this . columnList . toArray ( ) , ( col : IgxColumnComponent ) => this . columnInit . emit ( col ) ) ;
6828+ this . initColumns ( this . getColumnList ( ) , ( col : IgxColumnComponent ) => this . columnInit . emit ( col ) ) ;
67966829 if ( pinning ) {
67976830 this . initPinning ( ) ;
67986831 }
67996832
68006833 diff . forEachRemovedItem ( ( record : IterableChangeRecord < IgxColumnComponent | IgxColumnGroupComponent > ) => {
6834+ if ( this . getColumnList ( ) . indexOf ( record . item ) === - 1 ) {
6835+ return ;
6836+ }
68016837 const isColumnGroup = record . item instanceof IgxColumnGroupComponent ;
68026838 if ( ! isColumnGroup ) {
68036839 // Clear Grouping
0 commit comments