@@ -2441,6 +2441,11 @@ export class IgxGridBaseDirective extends DisplayDensityBase implements
2441
2441
*/
2442
2442
public columnWidthSetByUser = false ;
2443
2443
2444
+ /**
2445
+ * @hidden @internal
2446
+ */
2447
+ public pinnedRecords : any [ ] ;
2448
+
2444
2449
/**
2445
2450
* @hidden @internal
2446
2451
*/
@@ -2657,10 +2662,11 @@ export class IgxGridBaseDirective extends DisplayDensityBase implements
2657
2662
2658
2663
/**
2659
2664
* @hidden
2665
+ * Returns the row index of a row that takes into account the full view data like pinning.
2660
2666
*/
2661
- public getRowIndex ( rowIndex , pinned ) {
2667
+ public getDataViewIndex ( rowIndex , pinned ) {
2662
2668
if ( pinned && ! this . isRowPinningToTop ) {
2663
- rowIndex = rowIndex + this . dataView . length ;
2669
+ rowIndex = rowIndex + this . unpinnedRecords . length ;
2664
2670
} else if ( ! pinned && this . isRowPinningToTop ) {
2665
2671
rowIndex = rowIndex + this . pinnedRecordsCount ;
2666
2672
}
@@ -2719,6 +2725,15 @@ export class IgxGridBaseDirective extends DisplayDensityBase implements
2719
2725
return this . _pinnedRecordIDs . indexOf ( id ) !== - 1 ;
2720
2726
}
2721
2727
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
+
2722
2737
/**
2723
2738
* @hidden
2724
2739
* @internal
@@ -5154,25 +5169,38 @@ export class IgxGridBaseDirective extends DisplayDensityBase implements
5154
5169
}
5155
5170
5156
5171
/**
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.
5158
5173
* @example
5159
5174
* ```typescript
5160
- * const dataView = this.grid.dataView ;
5175
+ * const pinnedDataView = this.grid.pinnedDataView ;
5161
5176
* ```
5162
5177
*/
5163
- get dataView ( ) : any [ ] {
5164
- return this . unpinnedRecords ? this . unpinnedRecords : this . verticalScrollContainer . igxForOf ;
5178
+ get pinnedDataView ( ) : any [ ] {
5179
+ return this . pinnedRecords ? this . pinnedRecords : [ ] ;
5165
5180
}
5166
5181
5167
5182
/**
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.
5169
5184
* @example
5170
5185
* ```typescript
5171
5186
* const pinnedDataView = this.grid.pinnedDataView;
5172
5187
* ```
5173
5188
*/
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 ] ;
5176
5204
}
5177
5205
5178
5206
/**
@@ -5415,7 +5443,7 @@ export class IgxGridBaseDirective extends DisplayDensityBase implements
5415
5443
* If `headers` is enabled, it will use the column header (if any) instead of the column field.
5416
5444
*/
5417
5445
public getSelectedData ( formatters = false , headers = false ) {
5418
- const source = this . isRowPinningToTop ? [ ... this . pinnedDataView , ... this . dataView ] : [ ... this . dataView , ... this . pinnedDataView ] ;
5446
+ const source = this . dataView ;
5419
5447
return this . extractDataFromSelection ( source , formatters , headers ) ;
5420
5448
}
5421
5449
@@ -5619,10 +5647,14 @@ export class IgxGridBaseDirective extends DisplayDensityBase implements
5619
5647
if ( this . dataView . slice ( rowIndex , rowIndex + 1 ) . find ( rec => rec . expression || rec . childGridsData ) ) {
5620
5648
visibleColIndex = - 1 ;
5621
5649
}
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 ) ;
5623
5653
const shouldScrollHorizontally = this . navigation . shouldPerformHorizontalScroll ( visibleColIndex , rowIndex ) ;
5624
5654
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 ,
5626
5658
( ) => { this . navigateTo ( rowIndex , visibleColIndex , cb ) ; } ) ;
5627
5659
} else if ( shouldScrollHorizontally ) {
5628
5660
this . navigation . performHorizontalScrollToCell ( visibleColIndex , ( ) => { this . navigateTo ( rowIndex , visibleColIndex , cb ) ; } ) ;
@@ -5905,11 +5937,11 @@ export class IgxGridBaseDirective extends DisplayDensityBase implements
5905
5937
if ( delayScrolling ) {
5906
5938
this . verticalScrollContainer . onDataChanged . pipe ( first ( ) ) . subscribe ( ( ) => {
5907
5939
this . scrollDirective ( this . verticalScrollContainer ,
5908
- typeof ( row ) === 'number' ? row : this . dataView . indexOf ( row ) ) ;
5940
+ typeof ( row ) === 'number' ? row : this . unpinnedDataView . indexOf ( row ) ) ;
5909
5941
} ) ;
5910
5942
} else {
5911
5943
this . scrollDirective ( this . verticalScrollContainer ,
5912
- typeof ( row ) === 'number' ? row : this . dataView . indexOf ( row ) ) ;
5944
+ typeof ( row ) === 'number' ? row : this . unpinnedDataView . indexOf ( row ) ) ;
5913
5945
}
5914
5946
5915
5947
this . scrollToHorizontally ( column ) ;
0 commit comments