@@ -3664,9 +3664,8 @@ export class IgxGridBaseDirective extends DisplayDensityBase implements
3664
3664
/**
3665
3665
* @hidden
3666
3666
*/
3667
- protected _reorderPinnedColumns ( from : IgxColumnComponent , to : IgxColumnComponent , position : DropPosition ) {
3668
- const pinned = this . _pinnedColumns ;
3669
- let dropIndex = pinned . indexOf ( to ) ;
3667
+ protected _reorderColumns ( from : IgxColumnComponent , to : IgxColumnComponent , position : DropPosition , columnCollection : any [ ] ) {
3668
+ let dropIndex = columnCollection . indexOf ( to ) ;
3670
3669
3671
3670
if ( to . columnGroup ) {
3672
3671
dropIndex += to . allChildren . length ;
@@ -3680,9 +3679,8 @@ export class IgxGridBaseDirective extends DisplayDensityBase implements
3680
3679
dropIndex ++ ;
3681
3680
}
3682
3681
3683
- pinned . splice ( dropIndex , 0 , ...pinned . splice ( pinned . indexOf ( from ) , 1 ) ) ;
3682
+ columnCollection . splice ( dropIndex , 0 , ...columnCollection . splice ( columnCollection . indexOf ( from ) , 1 ) ) ;
3684
3683
}
3685
-
3686
3684
/**
3687
3685
* @hidden
3688
3686
*/
@@ -3735,18 +3733,25 @@ export class IgxGridBaseDirective extends DisplayDensityBase implements
3735
3733
}
3736
3734
3737
3735
if ( dropTarget . pinned && column . pinned ) {
3738
- this . _reorderPinnedColumns ( column , dropTarget , position ) ;
3736
+ this . _reorderColumns ( column , dropTarget , position , this . _pinnedColumns ) ;
3739
3737
}
3740
3738
3741
3739
if ( dropTarget . pinned && ! column . pinned ) {
3742
3740
column . pin ( ) ;
3743
- this . _reorderPinnedColumns ( column , dropTarget , position ) ;
3741
+ this . _reorderColumns ( column , dropTarget , position , this . _pinnedColumns ) ;
3742
+
3744
3743
}
3745
3744
3746
3745
if ( ! dropTarget . pinned && column . pinned ) {
3747
3746
column . unpin ( ) ;
3747
+ let list = [ ] ;
3748
+
3749
+ if ( this . pinnedColumns . indexOf ( column ) === - 1 && this . pinnedColumns . indexOf ( dropTarget ) === - 1 ) {
3750
+ list = this . _unpinnedColumns ;
3751
+ } else {
3752
+ list = this . _pinnedColumns ;
3753
+ }
3748
3754
3749
- const list = this . columnList . toArray ( ) ;
3750
3755
const fi = list . indexOf ( column ) ;
3751
3756
const ti = list . indexOf ( dropTarget ) ;
3752
3757
@@ -3759,6 +3764,10 @@ export class IgxGridBaseDirective extends DisplayDensityBase implements
3759
3764
}
3760
3765
}
3761
3766
3767
+ if ( ! dropTarget . pinned ) {
3768
+ this . _reorderColumns ( column , dropTarget , position , this . _unpinnedColumns ) ;
3769
+ }
3770
+
3762
3771
this . _moveColumns ( column , dropTarget , position ) ;
3763
3772
this . notifyChanges ( ) ;
3764
3773
if ( this . hasColumnLayouts ) {
@@ -4956,7 +4965,9 @@ export class IgxGridBaseDirective extends DisplayDensityBase implements
4956
4965
protected reinitPinStates ( ) {
4957
4966
this . _pinnedColumns = ( this . hasColumnGroups ) ? this . columnList . filter ( ( c ) => c . pinned ) :
4958
4967
this . columnList . filter ( ( c ) => c . pinned ) . sort ( ( a , b ) => this . _pinnedColumns . indexOf ( a ) - this . _pinnedColumns . indexOf ( b ) ) ;
4959
- this . _unpinnedColumns = this . columnList . filter ( ( c ) => ! c . pinned ) ;
4968
+ this . _unpinnedColumns = this . hasColumnGroups ? this . columnList . filter ( ( c ) => ! c . pinned ) :
4969
+ this . columnList . filter ( ( c ) => ! c . pinned )
4970
+ . sort ( ( a , b ) => this . _unpinnedColumns . indexOf ( a ) - this . _unpinnedColumns . indexOf ( b ) ) ;
4960
4971
}
4961
4972
4962
4973
/**
0 commit comments