@@ -6533,16 +6533,21 @@ export abstract class IgxGridBaseDirective extends DisplayDensityBase implements
65336533 if ( diff ) {
65346534 let added = false ;
65356535 let removed = false ;
6536+ let pinning = false ;
65366537 diff . forEachAddedItem ( ( record : IterableChangeRecord < IgxColumnComponent > ) => {
65376538 added = true ;
65386539 if ( record . item . pinned ) {
65396540 this . _pinnedColumns . push ( record . item ) ;
6541+ pinning = true ;
65406542 } else {
65416543 this . _unpinnedColumns . push ( record . item ) ;
65426544 }
65436545 } ) ;
65446546
65456547 this . initColumns ( this . columnList . toArray ( ) , ( col : IgxColumnComponent ) => this . columnInit . emit ( col ) ) ;
6548+ if ( pinning ) {
6549+ this . initPinning ( ) ;
6550+ }
65466551
65476552 diff . forEachRemovedItem ( ( record : IterableChangeRecord < IgxColumnComponent | IgxColumnGroupComponent > ) => {
65486553 const isColumnGroup = record . item instanceof IgxColumnGroupComponent ;
@@ -7151,42 +7156,9 @@ export abstract class IgxGridBaseDirective extends DisplayDensityBase implements
71517156 * @hidden
71527157 */
71537158 protected initPinning ( ) {
7154- const pinnedColumns = [ ] ;
7155- const unpinnedColumns = [ ] ;
7156-
71577159 this . calculateGridWidth ( ) ;
71587160 this . resetCaches ( ) ;
7159- // When a column is a group or is inside a group, pin all related.
7160- this . _pinnedColumns . forEach ( col => {
7161- if ( col . parent ) {
7162- col . parent . pinned = true ;
7163- }
7164- if ( col . columnGroup ) {
7165- col . children . forEach ( child => child . pinned = true ) ;
7166- }
7167- } ) ;
7168-
7169- // Make sure we don't exceed unpinned area min width and get pinned and unpinned col collections.
7170- // We take into account top level columns (top level groups and non groups).
7171- // If top level is unpinned the pinning handles all children to be unpinned as well.
7172- for ( const column of this . _columns ) {
7173- if ( column . pinned && ! column . parent ) {
7174- pinnedColumns . push ( column ) ;
7175- } else if ( column . pinned && column . parent ) {
7176- if ( column . topLevelParent . pinned ) {
7177- pinnedColumns . push ( column ) ;
7178- } else {
7179- column . pinned = false ;
7180- unpinnedColumns . push ( column ) ;
7181- }
7182- } else {
7183- unpinnedColumns . push ( column ) ;
7184- }
7185- }
7186-
7187- // Assign the applicable collections.
7188- this . _pinnedColumns = pinnedColumns ;
7189- this . _unpinnedColumns = unpinnedColumns ;
7161+ this . handleColumnPinningForGroups ( ) ;
71907162 this . notifyChanges ( ) ;
71917163 }
71927164
@@ -7618,4 +7590,40 @@ export abstract class IgxGridBaseDirective extends DisplayDensityBase implements
76187590 settings . target = targetRow . element . nativeElement ;
76197591 this . toggleRowEditingOverlay ( true ) ;
76207592 }
7593+
7594+ private handleColumnPinningForGroups ( ) : void {
7595+ // When a column is a group or is inside a group, pin all related.
7596+ const pinnedColumns = [ ] ;
7597+ const unpinnedColumns = [ ] ;
7598+
7599+ this . _pinnedColumns . forEach ( col => {
7600+ if ( col . parent ) {
7601+ col . parent . pinned = true ;
7602+ }
7603+ if ( col . columnGroup ) {
7604+ col . children . forEach ( child => child . pinned = true ) ;
7605+ }
7606+ } ) ;
7607+
7608+ // Make sure we don't exceed unpinned area min width and get pinned and unpinned col collections.
7609+ // We take into account top level columns (top level groups and non groups).
7610+ // If top level is unpinned the pinning handles all children to be unpinned as well.
7611+ for ( const column of this . _columns ) {
7612+ if ( column . pinned && ! column . parent ) {
7613+ pinnedColumns . push ( column ) ;
7614+ } else if ( column . pinned && column . parent ) {
7615+ if ( column . topLevelParent . pinned ) {
7616+ pinnedColumns . push ( column ) ;
7617+ } else {
7618+ column . pinned = false ;
7619+ unpinnedColumns . push ( column ) ;
7620+ }
7621+ } else {
7622+ unpinnedColumns . push ( column ) ;
7623+ }
7624+ }
7625+ // Assign the applicable collections.
7626+ this . _pinnedColumns = pinnedColumns ;
7627+ this . _unpinnedColumns = unpinnedColumns ;
7628+ }
76217629}
0 commit comments