@@ -590,6 +590,46 @@ export class IgxColumnComponent implements AfterContentInit {
590
590
}
591
591
}
592
592
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
+
593
633
/**
594
634
*@hidden
595
635
*/
@@ -904,6 +944,7 @@ export class IgxColumnComponent implements AfterContentInit {
904
944
}
905
945
const unpinnedColumns = this . grid . unpinnedColumns . filter ( c => ! c . columnGroup ) ;
906
946
const pinnedColumns = this . grid . pinnedColumns . filter ( c => ! c . columnGroup ) ;
947
+ const pinnedRightColumns = this . grid . pinnedRightColumns . filter ( c => ! c . columnGroup ) ;
907
948
let col = this ;
908
949
let vIndex = - 1 ;
909
950
@@ -914,11 +955,14 @@ export class IgxColumnComponent implements AfterContentInit {
914
955
return this . parent . childrenVisibleIndexes . find ( x => x . column === this ) . index ;
915
956
}
916
957
917
- if ( ! this . pinned ) {
958
+ if ( ! this . pinned && ! this . pinnedToRight ) {
918
959
const indexInCollection = unpinnedColumns . indexOf ( col ) ;
919
960
vIndex = indexInCollection === - 1 ? - 1 : pinnedColumns . length + indexInCollection ;
920
- } else {
961
+ } else if ( this . pinned ) {
921
962
vIndex = pinnedColumns . indexOf ( col ) ;
963
+ } else {
964
+ const indexInCollection = pinnedRightColumns . indexOf ( this ) ;
965
+ vIndex = indexInCollection === - 1 ? - 1 : pinnedColumns . length + unpinnedColumns . length + indexInCollection ;
922
966
}
923
967
this . _vIndex = vIndex ;
924
968
return vIndex ;
@@ -988,6 +1032,17 @@ export class IgxColumnComponent implements AfterContentInit {
988
1032
get isLastPinned ( ) : boolean {
989
1033
return this . grid . pinnedColumns [ this . grid . pinnedColumns . length - 1 ] === this ;
990
1034
}
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
+
991
1046
get gridRowSpan ( ) : number {
992
1047
return this . rowEnd && this . rowStart ? this . rowEnd - this . rowStart : 1 ;
993
1048
}
@@ -1127,6 +1182,10 @@ export class IgxColumnComponent implements AfterContentInit {
1127
1182
*@hidden
1128
1183
*/
1129
1184
protected _pinned = false ;
1185
+ /**
1186
+ *@hidden
1187
+ */
1188
+ protected _pinnedToRight = false ;
1130
1189
/**
1131
1190
*@hidden
1132
1191
*/
@@ -1545,6 +1604,73 @@ export class IgxColumnComponent implements AfterContentInit {
1545
1604
this . grid . filteringService . refreshExpressions ( ) ;
1546
1605
return true ;
1547
1606
}
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
+ }
1548
1674
/**
1549
1675
* Unpins the column and place it at the provided index in the unpinned area. Defaults to index `0` if not provided.
1550
1676
* 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 {
1560
1686
if ( this . grid ) {
1561
1687
this . grid . endEdit ( true ) ;
1562
1688
}
1563
- if ( ! this . _pinned ) {
1689
+ if ( ! this . _pinned && ! this . _pinnedToRight ) {
1564
1690
return false ;
1565
1691
}
1566
1692
@@ -1577,6 +1703,7 @@ export class IgxColumnComponent implements AfterContentInit {
1577
1703
index = ( index !== undefined ? index :
1578
1704
this . _unpinnedIndex !== undefined ? this . _unpinnedIndex : this . index ) ;
1579
1705
this . _pinned = false ;
1706
+ this . _pinnedToRight = false ;
1580
1707
this . pinnedChange . emit ( this . _pinned ) ;
1581
1708
1582
1709
const targetColumn = grid . _unpinnedColumns [ index ] ;
@@ -1585,6 +1712,9 @@ export class IgxColumnComponent implements AfterContentInit {
1585
1712
if ( grid . _pinnedColumns . indexOf ( this ) !== - 1 ) {
1586
1713
grid . _pinnedColumns . splice ( grid . _pinnedColumns . indexOf ( this ) , 1 ) ;
1587
1714
}
1715
+ if ( grid . _pinnedRightColumns . indexOf ( this ) !== - 1 ) {
1716
+ grid . _pinnedRightColumns . splice ( grid . _pinnedRightColumns . indexOf ( this ) , 1 ) ;
1717
+ }
1588
1718
1589
1719
if ( hasIndex ) {
1590
1720
grid . _moveColumns ( this , targetColumn ) ;
0 commit comments