@@ -2441,6 +2441,11 @@ export class IgxGridBaseDirective extends DisplayDensityBase implements
24412441 */
24422442 public columnWidthSetByUser = false ;
24432443
2444+ /**
2445+ * @hidden @internal
2446+ */
2447+ public pinnedRecords : any [ ] ;
2448+
24442449 /**
24452450 * @hidden @internal
24462451 */
@@ -2657,10 +2662,11 @@ export class IgxGridBaseDirective extends DisplayDensityBase implements
26572662
26582663 /**
26592664 * @hidden
2665+ * Returns the row index of a row that takes into account the full view data like pinning.
26602666 */
2661- public getRowIndex ( rowIndex , pinned ) {
2667+ public getDataViewIndex ( rowIndex , pinned ) {
26622668 if ( pinned && ! this . isRowPinningToTop ) {
2663- rowIndex = rowIndex + this . dataView . length ;
2669+ rowIndex = rowIndex + this . unpinnedRecords . length ;
26642670 } else if ( ! pinned && this . isRowPinningToTop ) {
26652671 rowIndex = rowIndex + this . pinnedRecordsCount ;
26662672 }
@@ -2719,6 +2725,15 @@ export class IgxGridBaseDirective extends DisplayDensityBase implements
27192725 return this . _pinnedRecordIDs . indexOf ( id ) !== - 1 ;
27202726 }
27212727
2728+ /**
2729+ * @hidden
2730+ * @internal
2731+ */
2732+ public isRecordPinnedByIndex ( rowIndex : number ) {
2733+ return this . hasPinnedRecords && ( this . isRowPinningToTop && rowIndex < this . pinnedRecordsCount ) ||
2734+ ( ! this . isRowPinningToTop && rowIndex >= this . unpinnedRecords . length ) ;
2735+ }
2736+
27222737 /**
27232738 * @hidden
27242739 * @internal
@@ -5154,25 +5169,38 @@ export class IgxGridBaseDirective extends DisplayDensityBase implements
51545169 }
51555170
51565171 /**
5157- * Returns the currently transformed paged/filtered/sorted/grouped data, displayed in the grid.
5172+ * Returns the currently transformed paged/filtered/sorted/grouped pinned row data, displayed in the grid.
51585173 * @example
51595174 * ```typescript
5160- * const dataView = this.grid.dataView ;
5175+ * const pinnedDataView = this.grid.pinnedDataView ;
51615176 * ```
51625177 */
5163- get dataView ( ) : any [ ] {
5164- return this . unpinnedRecords ? this . unpinnedRecords : this . verticalScrollContainer . igxForOf ;
5178+ get pinnedDataView ( ) : any [ ] {
5179+ return this . pinnedRecords ? this . pinnedRecords : [ ] ;
51655180 }
51665181
51675182 /**
5168- * Returns the currently transformed paged/filtered/sorted/grouped pinned data, displayed in the grid.
5183+ * Returns currently transformed paged/filtered/sorted/grouped unpinned row data, displayed in the grid.
51695184 * @example
51705185 * ```typescript
51715186 * const pinnedDataView = this.grid.pinnedDataView;
51725187 * ```
51735188 */
5174- get pinnedDataView ( ) : any [ ] {
5175- return this . pinnedRows . map ( row => row . rowData ) ;
5189+ get unpinnedDataView ( ) : any [ ] {
5190+ return this . unpinnedRecords ? this . unpinnedRecords : this . verticalScrollContainer . igxForOf ;
5191+ }
5192+
5193+ /**
5194+ * Returns the currently transformed paged/filtered/sorted/grouped row data, displayed in the grid.
5195+ * @example
5196+ * ```typescript
5197+ * const dataView = this.grid.dataView;
5198+ * ```
5199+ */
5200+ get dataView ( ) : any [ ] {
5201+ return this . isRowPinningToTop ?
5202+ [ ...this . pinnedDataView , ...this . unpinnedDataView ] :
5203+ [ ...this . unpinnedDataView , ...this . pinnedDataView ] ;
51765204 }
51775205
51785206 /**
@@ -5415,7 +5443,7 @@ export class IgxGridBaseDirective extends DisplayDensityBase implements
54155443 * If `headers` is enabled, it will use the column header (if any) instead of the column field.
54165444 */
54175445 public getSelectedData ( formatters = false , headers = false ) {
5418- const source = this . isRowPinningToTop ? [ ... this . pinnedDataView , ... this . dataView ] : [ ... this . dataView , ... this . pinnedDataView ] ;
5446+ const source = this . dataView ;
54195447 return this . extractDataFromSelection ( source , formatters , headers ) ;
54205448 }
54215449
@@ -5619,10 +5647,14 @@ export class IgxGridBaseDirective extends DisplayDensityBase implements
56195647 if ( this . dataView . slice ( rowIndex , rowIndex + 1 ) . find ( rec => rec . expression || rec . childGridsData ) ) {
56205648 visibleColIndex = - 1 ;
56215649 }
5622- const shouldScrollVertically = this . navigation . shouldPerformVerticalScroll ( rowIndex , visibleColIndex ) ;
5650+ // If the target row is pinned no need to scroll as well.
5651+ const shouldScrollVertically =
5652+ ! this . isRecordPinnedByIndex ( rowIndex ) && this . navigation . shouldPerformVerticalScroll ( rowIndex , visibleColIndex ) ;
56235653 const shouldScrollHorizontally = this . navigation . shouldPerformHorizontalScroll ( visibleColIndex , rowIndex ) ;
56245654 if ( shouldScrollVertically ) {
5625- this . navigation . performVerticalScrollToCell ( rowIndex , visibleColIndex ,
5655+ // Only for top pinning we need to subtract pinned count because virtualization indexing doesn't count pinned rows.
5656+ const scrollRowIndex = this . isRowPinningToTop ? rowIndex - this . pinnedRecordsCount : rowIndex ;
5657+ this . navigation . performVerticalScrollToCell ( scrollRowIndex , visibleColIndex ,
56265658 ( ) => { this . navigateTo ( rowIndex , visibleColIndex , cb ) ; } ) ;
56275659 } else if ( shouldScrollHorizontally ) {
56285660 this . navigation . performHorizontalScrollToCell ( visibleColIndex , ( ) => { this . navigateTo ( rowIndex , visibleColIndex , cb ) ; } ) ;
@@ -5905,11 +5937,11 @@ export class IgxGridBaseDirective extends DisplayDensityBase implements
59055937 if ( delayScrolling ) {
59065938 this . verticalScrollContainer . onDataChanged . pipe ( first ( ) ) . subscribe ( ( ) => {
59075939 this . scrollDirective ( this . verticalScrollContainer ,
5908- typeof ( row ) === 'number' ? row : this . dataView . indexOf ( row ) ) ;
5940+ typeof ( row ) === 'number' ? row : this . unpinnedDataView . indexOf ( row ) ) ;
59095941 } ) ;
59105942 } else {
59115943 this . scrollDirective ( this . verticalScrollContainer ,
5912- typeof ( row ) === 'number' ? row : this . dataView . indexOf ( row ) ) ;
5944+ typeof ( row ) === 'number' ? row : this . unpinnedDataView . indexOf ( row ) ) ;
59135945 }
59145946
59155947 this . scrollToHorizontally ( column ) ;
0 commit comments