@@ -2444,6 +2444,11 @@ export class IgxGridBaseDirective extends DisplayDensityBase implements
24442444 */
24452445 public columnWidthSetByUser = false ;
24462446
2447+ /**
2448+ * @hidden @internal
2449+ */
2450+ public pinnedRecords : any [ ] ;
2451+
24472452 /**
24482453 * @hidden @internal
24492454 */
@@ -2665,12 +2670,13 @@ export class IgxGridBaseDirective extends DisplayDensityBase implements
26652670
26662671 /**
26672672 * @hidden
2673+ * Returns the row index of a row that takes into account the full view data like pinning.
26682674 */
2669- public getRowIndex ( rowIndex , pinned ) {
2675+ public getDataViewIndex ( rowIndex , pinned ) {
26702676 if ( pinned && ! this . isRowPinningToTop ) {
2671- rowIndex = rowIndex + this . dataView . length ;
2677+ rowIndex = rowIndex + this . unpinnedDataView . length ;
26722678 } else if ( ! pinned && this . isRowPinningToTop ) {
2673- rowIndex = rowIndex + this . pinnedRecordsCount ;
2679+ rowIndex = rowIndex + this . pinnedDataView . length ;
26742680 }
26752681 return rowIndex ;
26762682 }
@@ -2727,6 +2733,15 @@ export class IgxGridBaseDirective extends DisplayDensityBase implements
27272733 return this . _pinnedRecordIDs . indexOf ( id ) !== - 1 ;
27282734 }
27292735
2736+ /**
2737+ * @hidden
2738+ * @internal
2739+ */
2740+ public isRecordPinnedByIndex ( rowIndex : number ) {
2741+ return this . hasPinnedRecords && ( this . isRowPinningToTop && rowIndex < this . pinnedDataView . length ) ||
2742+ ( ! this . isRowPinningToTop && rowIndex >= this . unpinnedDataView . length ) ;
2743+ }
2744+
27302745 /**
27312746 * @hidden
27322747 * @internal
@@ -2997,6 +3012,7 @@ export class IgxGridBaseDirective extends DisplayDensityBase implements
29973012 data = data . map ( rec => rec . ghostRecord !== undefined ? rec . recordRef : rec ) ;
29983013 if ( this . _pinnedRecordIDs . length > 0 && pinned ) {
29993014 this . _filteredSortedPinnedData = data ;
3015+ this . pinnedRecords = data ;
30003016 this . filteredSortedData = this . isRowPinningToTop ? [ ... this . _filteredSortedPinnedData , ... this . _filteredSortedUnpinnedData ] :
30013017 [ ... this . _filteredSortedUnpinnedData , ... this . _filteredSortedPinnedData ] ;
30023018 } else if ( this . _pinnedRecordIDs . length > 0 && ! pinned ) {
@@ -5172,25 +5188,38 @@ export class IgxGridBaseDirective extends DisplayDensityBase implements
51725188 }
51735189
51745190 /**
5175- * Returns the currently transformed paged/filtered/sorted/grouped data, displayed in the grid.
5191+ * Returns the currently transformed paged/filtered/sorted/grouped pinned row data, displayed in the grid.
51765192 * @example
51775193 * ```typescript
5178- * const dataView = this.grid.dataView ;
5194+ * const pinnedDataView = this.grid.pinnedDataView ;
51795195 * ```
51805196 */
5181- get dataView ( ) : any [ ] {
5197+ get pinnedDataView ( ) : any [ ] {
5198+ return this . pinnedRecords ? this . pinnedRecords : [ ] ;
5199+ }
5200+
5201+ /**
5202+ * Returns currently transformed paged/filtered/sorted/grouped unpinned row data, displayed in the grid.
5203+ * @example
5204+ * ```typescript
5205+ * const pinnedDataView = this.grid.pinnedDataView;
5206+ * ```
5207+ */
5208+ get unpinnedDataView ( ) : any [ ] {
51825209 return this . unpinnedRecords ? this . unpinnedRecords : this . verticalScrollContainer . igxForOf ;
51835210 }
51845211
5185- /**
5186- * Returns the currently transformed paged/filtered/sorted/grouped pinned data, displayed in the grid.
5187- * @example
5188- * ```typescript
5189- * const pinnedDataView = this.grid.pinnedDataView;
5190- * ```
5191- */
5192- get pinnedDataView ( ) : any [ ] {
5193- return this . pinnedRows . map ( row => row . rowData ) ;
5212+ /**
5213+ * Returns the currently transformed paged/filtered/sorted/grouped/pinned/unpinned row data, displayed in the grid.
5214+ * @example
5215+ * ```typescript
5216+ * const dataView = this.grid.dataView;
5217+ * ```
5218+ */
5219+ get dataView ( ) : any [ ] {
5220+ return this . isRowPinningToTop ?
5221+ [ ...this . pinnedDataView , ...this . unpinnedDataView ] :
5222+ [ ...this . unpinnedDataView , ...this . pinnedDataView ] ;
51945223 }
51955224
51965225 /**
@@ -5433,7 +5462,7 @@ export class IgxGridBaseDirective extends DisplayDensityBase implements
54335462 * If `headers` is enabled, it will use the column header (if any) instead of the column field.
54345463 */
54355464 public getSelectedData ( formatters = false , headers = false ) {
5436- const source = this . isRowPinningToTop ? [ ... this . pinnedDataView , ... this . dataView ] : [ ... this . dataView , ... this . pinnedDataView ] ;
5465+ const source = this . filteredSortedData ;
54375466 return this . extractDataFromSelection ( source , formatters , headers ) ;
54385467 }
54395468
@@ -5637,6 +5666,7 @@ export class IgxGridBaseDirective extends DisplayDensityBase implements
56375666 if ( this . dataView . slice ( rowIndex , rowIndex + 1 ) . find ( rec => rec . expression || rec . childGridsData ) ) {
56385667 visibleColIndex = - 1 ;
56395668 }
5669+ // If the target row is pinned no need to scroll as well.
56405670 const shouldScrollVertically = this . navigation . shouldPerformVerticalScroll ( rowIndex , visibleColIndex ) ;
56415671 const shouldScrollHorizontally = this . navigation . shouldPerformHorizontalScroll ( visibleColIndex , rowIndex ) ;
56425672 if ( shouldScrollVertically ) {
@@ -5923,11 +5953,11 @@ export class IgxGridBaseDirective extends DisplayDensityBase implements
59235953 if ( delayScrolling ) {
59245954 this . verticalScrollContainer . onDataChanged . pipe ( first ( ) ) . subscribe ( ( ) => {
59255955 this . scrollDirective ( this . verticalScrollContainer ,
5926- typeof ( row ) === 'number' ? row : this . dataView . indexOf ( row ) ) ;
5956+ typeof ( row ) === 'number' ? row : this . unpinnedDataView . indexOf ( row ) ) ;
59275957 } ) ;
59285958 } else {
59295959 this . scrollDirective ( this . verticalScrollContainer ,
5930- typeof ( row ) === 'number' ? row : this . dataView . indexOf ( row ) ) ;
5960+ typeof ( row ) === 'number' ? row : this . unpinnedDataView . indexOf ( row ) ) ;
59315961 }
59325962
59335963 this . scrollToHorizontally ( column ) ;
0 commit comments