@@ -590,6 +590,46 @@ export class IgxColumnComponent implements AfterContentInit {
590590 }
591591 }
592592
593+ /**
594+ * Gets whether the column is `pinnedToRight`.
595+ * ```typescript
596+ * let isPinnedToRight = this.column.pinnedToRight;
597+ * ```
598+ * @memberof IgxColumnComponent
599+ */
600+ @WatchColumnChanges ( )
601+ @Input ( )
602+ public get pinnedToRight ( ) : boolean {
603+ return this . _pinnedToRight ;
604+ }
605+ /**
606+ * Sets whether the column is pinned.
607+ * Default value is `false`.
608+ * ```html
609+ * <igx-column [pinnedToRight] = "true"></igx-column>
610+ * ```
611+ *
612+ * Two-way data binding.
613+ * ```html
614+ * <igx-column [(pinnedToRight)] = "model.columns[0].isPinnedToRight"></igx-column>
615+ * ```
616+ * @memberof IgxColumnComponent
617+ */
618+ public set pinnedToRight ( value : boolean ) {
619+ if ( this . _pinnedToRight !== value ) {
620+ if ( this . grid && this . width && ! isNaN ( parseInt ( this . width , 10 ) ) ) {
621+ value ? this . pinToRight ( ) : this . unpin ( ) ;
622+ return ;
623+ }
624+ /* No grid/width available at initialization. `initPinning` in the grid
625+ will re-init the group (if present)
626+ */
627+ this . _unpinnedIndex = this . grid ? this . grid . columns . filter ( x => ! x . _pinnedToRight ) . indexOf ( this ) : 0 ;
628+ this . _pinnedToRight = value ;
629+ this . pinnedChange . emit ( this . _pinnedToRight ) ;
630+ }
631+ }
632+
593633 /**
594634 *@hidden
595635 */
@@ -904,6 +944,7 @@ export class IgxColumnComponent implements AfterContentInit {
904944 }
905945 const unpinnedColumns = this . grid . unpinnedColumns . filter ( c => ! c . columnGroup ) ;
906946 const pinnedColumns = this . grid . pinnedColumns . filter ( c => ! c . columnGroup ) ;
947+ const pinnedRightColumns = this . grid . pinnedRightColumns . filter ( c => ! c . columnGroup ) ;
907948 let col = this ;
908949 let vIndex = - 1 ;
909950
@@ -914,11 +955,14 @@ export class IgxColumnComponent implements AfterContentInit {
914955 return this . parent . childrenVisibleIndexes . find ( x => x . column === this ) . index ;
915956 }
916957
917- if ( ! this . pinned ) {
958+ if ( ! this . pinned && ! this . pinnedToRight ) {
918959 const indexInCollection = unpinnedColumns . indexOf ( col ) ;
919960 vIndex = indexInCollection === - 1 ? - 1 : pinnedColumns . length + indexInCollection ;
920- } else {
961+ } else if ( this . pinned ) {
921962 vIndex = pinnedColumns . indexOf ( col ) ;
963+ } else {
964+ const indexInCollection = pinnedRightColumns . indexOf ( this ) ;
965+ vIndex = indexInCollection === - 1 ? - 1 : pinnedColumns . length + unpinnedColumns . length + indexInCollection ;
922966 }
923967 this . _vIndex = vIndex ;
924968 return vIndex ;
@@ -988,6 +1032,17 @@ export class IgxColumnComponent implements AfterContentInit {
9881032 get isLastPinned ( ) : boolean {
9891033 return this . grid . pinnedColumns [ this . grid . pinnedColumns . length - 1 ] === this ;
9901034 }
1035+
1036+ get isFirstPinned ( ) : boolean {
1037+ return this . grid . pinnedRightColumns [ 0 ] === this ;
1038+ }
1039+
1040+ get rightPinnedOffset ( ) : string {
1041+ return this . pinnedToRight ?
1042+ - ( this . grid . pinnedWidth + this . grid . rightPinnedWidth ) + 'px' :
1043+ null ;
1044+ }
1045+
9911046 get gridRowSpan ( ) : number {
9921047 return this . rowEnd && this . rowStart ? this . rowEnd - this . rowStart : 1 ;
9931048 }
@@ -1127,6 +1182,10 @@ export class IgxColumnComponent implements AfterContentInit {
11271182 *@hidden
11281183 */
11291184 protected _pinned = false ;
1185+ /**
1186+ *@hidden
1187+ */
1188+ protected _pinnedToRight = false ;
11301189 /**
11311190 *@hidden
11321191 */
@@ -1545,6 +1604,73 @@ export class IgxColumnComponent implements AfterContentInit {
15451604 this . grid . filteringService . refreshExpressions ( ) ;
15461605 return true ;
15471606 }
1607+ /**
1608+ * Pins the column at the provided index in the pinned area to the right. Defaults to index `0` if not provided.
1609+ * Returns `true` if the column is successfully pinned. Returns `false` if the column cannot be pinned.
1610+ * Column cannot be pinned if:
1611+ * - Is already pinned
1612+ * - index argument is out of range
1613+ * - The pinned area exceeds 80% of the grid width
1614+ * ```typescript
1615+ * let success = this.column.pin();
1616+ * ```
1617+ * @memberof IgxColumnComponent
1618+ */
1619+ public pinToRight ( index ?: number ) : boolean {
1620+ if ( this . grid ) {
1621+ this . grid . endEdit ( true ) ;
1622+ }
1623+ if ( this . _pinnedToRight ) {
1624+ return false ;
1625+ }
1626+
1627+ if ( this . parent && ! this . parent . pinnedToRight ) {
1628+ return this . topLevelParent . pinToRight ( index ) ;
1629+ }
1630+
1631+ const grid = ( this . grid as any ) ;
1632+ const hasIndex = index !== undefined ;
1633+ if ( hasIndex && ( index < 0 || index >= grid . pinnedToRightColumns . length ) ) {
1634+ return false ;
1635+ }
1636+
1637+ if ( ! this . parent && ! this . pinnable ) {
1638+ return false ;
1639+ }
1640+
1641+ this . _pinnedToRight = true ;
1642+ this . pinnedChange . emit ( this . _pinnedToRight ) ;
1643+ this . _unpinnedIndex = grid . _unpinnedColumns . indexOf ( this ) ;
1644+ index = index !== undefined ? index : grid . _pinnedRightColumns . length ;
1645+ const targetColumn = grid . _pinnedRightColumns [ index ] ;
1646+ const args = { column : this , insertAtIndex : index , isPinned : true } ;
1647+ grid . onColumnPinning . emit ( args ) ;
1648+
1649+ if ( grid . _pinnedRightColumns . indexOf ( this ) === - 1 ) {
1650+ grid . _pinnedRightColumns . splice ( args . insertAtIndex , 0 , this ) ;
1651+
1652+ if ( grid . _unpinnedColumns . indexOf ( this ) !== - 1 ) {
1653+ grid . _unpinnedColumns . splice ( grid . _unpinnedColumns . indexOf ( this ) , 1 ) ;
1654+ }
1655+ }
1656+
1657+ if ( hasIndex ) {
1658+ grid . _moveColumns ( this , targetColumn ) ;
1659+ }
1660+
1661+ if ( this . columnGroup ) {
1662+ this . allChildren . forEach ( child => child . pinToRight ( ) ) ;
1663+ grid . reinitPinStates ( ) ;
1664+ }
1665+
1666+ grid . resetCaches ( ) ;
1667+ grid . notifyChanges ( ) ;
1668+ if ( this . columnLayoutChild ) {
1669+ this . grid . columns . filter ( x => x . columnLayout ) . forEach ( x => x . populateVisibleIndexes ( ) ) ;
1670+ }
1671+ this . grid . filteringService . refreshExpressions ( ) ;
1672+ return true ;
1673+ }
15481674 /**
15491675 * Unpins the column and place it at the provided index in the unpinned area. Defaults to index `0` if not provided.
15501676 * Returns `true` if the column is successfully unpinned. Returns `false` if the column cannot be unpinned.
@@ -1560,7 +1686,7 @@ export class IgxColumnComponent implements AfterContentInit {
15601686 if ( this . grid ) {
15611687 this . grid . endEdit ( true ) ;
15621688 }
1563- if ( ! this . _pinned ) {
1689+ if ( ! this . _pinned && ! this . _pinnedToRight ) {
15641690 return false ;
15651691 }
15661692
@@ -1577,6 +1703,7 @@ export class IgxColumnComponent implements AfterContentInit {
15771703 index = ( index !== undefined ? index :
15781704 this . _unpinnedIndex !== undefined ? this . _unpinnedIndex : this . index ) ;
15791705 this . _pinned = false ;
1706+ this . _pinnedToRight = false ;
15801707 this . pinnedChange . emit ( this . _pinned ) ;
15811708
15821709 const targetColumn = grid . _unpinnedColumns [ index ] ;
@@ -1585,6 +1712,9 @@ export class IgxColumnComponent implements AfterContentInit {
15851712 if ( grid . _pinnedColumns . indexOf ( this ) !== - 1 ) {
15861713 grid . _pinnedColumns . splice ( grid . _pinnedColumns . indexOf ( this ) , 1 ) ;
15871714 }
1715+ if ( grid . _pinnedRightColumns . indexOf ( this ) !== - 1 ) {
1716+ grid . _pinnedRightColumns . splice ( grid . _pinnedRightColumns . indexOf ( this ) , 1 ) ;
1717+ }
15881718
15891719 if ( hasIndex ) {
15901720 grid . _moveColumns ( this , targetColumn ) ;
0 commit comments