@@ -6540,16 +6540,21 @@ export abstract class IgxGridBaseDirective extends DisplayDensityBase implements
65406540 if ( diff ) {
65416541 let added = false ;
65426542 let removed = false ;
6543+ let pinning = false ;
65436544 diff . forEachAddedItem ( ( record : IterableChangeRecord < IgxColumnComponent > ) => {
65446545 added = true ;
65456546 if ( record . item . pinned ) {
65466547 this . _pinnedColumns . push ( record . item ) ;
6548+ pinning = true ;
65476549 } else {
65486550 this . _unpinnedColumns . push ( record . item ) ;
65496551 }
65506552 } ) ;
65516553
65526554 this . initColumns ( this . columnList . toArray ( ) , ( col : IgxColumnComponent ) => this . columnInit . emit ( col ) ) ;
6555+ if ( pinning ) {
6556+ this . initPinning ( ) ;
6557+ }
65536558
65546559 diff . forEachRemovedItem ( ( record : IterableChangeRecord < IgxColumnComponent | IgxColumnGroupComponent > ) => {
65556560 const isColumnGroup = record . item instanceof IgxColumnGroupComponent ;
@@ -7158,42 +7163,9 @@ export abstract class IgxGridBaseDirective extends DisplayDensityBase implements
71587163 * @hidden
71597164 */
71607165 protected initPinning ( ) {
7161- const pinnedColumns = [ ] ;
7162- const unpinnedColumns = [ ] ;
7163-
71647166 this . calculateGridWidth ( ) ;
71657167 this . resetCaches ( ) ;
7166- // When a column is a group or is inside a group, pin all related.
7167- this . _pinnedColumns . forEach ( col => {
7168- if ( col . parent ) {
7169- col . parent . pinned = true ;
7170- }
7171- if ( col . columnGroup ) {
7172- col . children . forEach ( child => child . pinned = true ) ;
7173- }
7174- } ) ;
7175-
7176- // Make sure we don't exceed unpinned area min width and get pinned and unpinned col collections.
7177- // We take into account top level columns (top level groups and non groups).
7178- // If top level is unpinned the pinning handles all children to be unpinned as well.
7179- for ( const column of this . _columns ) {
7180- if ( column . pinned && ! column . parent ) {
7181- pinnedColumns . push ( column ) ;
7182- } else if ( column . pinned && column . parent ) {
7183- if ( column . topLevelParent . pinned ) {
7184- pinnedColumns . push ( column ) ;
7185- } else {
7186- column . pinned = false ;
7187- unpinnedColumns . push ( column ) ;
7188- }
7189- } else {
7190- unpinnedColumns . push ( column ) ;
7191- }
7192- }
7193-
7194- // Assign the applicable collections.
7195- this . _pinnedColumns = pinnedColumns ;
7196- this . _unpinnedColumns = unpinnedColumns ;
7168+ this . handleColumnPinningForGroups ( ) ;
71977169 this . notifyChanges ( ) ;
71987170 }
71997171
@@ -7625,4 +7597,40 @@ export abstract class IgxGridBaseDirective extends DisplayDensityBase implements
76257597 settings . target = targetRow . element . nativeElement ;
76267598 this . toggleRowEditingOverlay ( true ) ;
76277599 }
7600+
7601+ private handleColumnPinningForGroups ( ) : void {
7602+ // When a column is a group or is inside a group, pin all related.
7603+ const pinnedColumns = [ ] ;
7604+ const unpinnedColumns = [ ] ;
7605+
7606+ this . _pinnedColumns . forEach ( col => {
7607+ if ( col . parent ) {
7608+ col . parent . pinned = true ;
7609+ }
7610+ if ( col . columnGroup ) {
7611+ col . children . forEach ( child => child . pinned = true ) ;
7612+ }
7613+ } ) ;
7614+
7615+ // Make sure we don't exceed unpinned area min width and get pinned and unpinned col collections.
7616+ // We take into account top level columns (top level groups and non groups).
7617+ // If top level is unpinned the pinning handles all children to be unpinned as well.
7618+ for ( const column of this . _columns ) {
7619+ if ( column . pinned && ! column . parent ) {
7620+ pinnedColumns . push ( column ) ;
7621+ } else if ( column . pinned && column . parent ) {
7622+ if ( column . topLevelParent . pinned ) {
7623+ pinnedColumns . push ( column ) ;
7624+ } else {
7625+ column . pinned = false ;
7626+ unpinnedColumns . push ( column ) ;
7627+ }
7628+ } else {
7629+ unpinnedColumns . push ( column ) ;
7630+ }
7631+ }
7632+ // Assign the applicable collections.
7633+ this . _pinnedColumns = pinnedColumns ;
7634+ this . _unpinnedColumns = unpinnedColumns ;
7635+ }
76287636}
0 commit comments