@@ -2444,6 +2444,11 @@ export class IgxGridBaseDirective extends DisplayDensityBase implements
2444
2444
*/
2445
2445
public columnWidthSetByUser = false ;
2446
2446
2447
+ /**
2448
+ * @hidden @internal
2449
+ */
2450
+ public pinnedRecords : any [ ] ;
2451
+
2447
2452
/**
2448
2453
* @hidden @internal
2449
2454
*/
@@ -2665,12 +2670,13 @@ export class IgxGridBaseDirective extends DisplayDensityBase implements
2665
2670
2666
2671
/**
2667
2672
* @hidden
2673
+ * Returns the row index of a row that takes into account the full view data like pinning.
2668
2674
*/
2669
- public getRowIndex ( rowIndex , pinned ) {
2675
+ public getDataViewIndex ( rowIndex , pinned ) {
2670
2676
if ( pinned && ! this . isRowPinningToTop ) {
2671
- rowIndex = rowIndex + this . dataView . length ;
2677
+ rowIndex = rowIndex + this . unpinnedDataView . length ;
2672
2678
} else if ( ! pinned && this . isRowPinningToTop ) {
2673
- rowIndex = rowIndex + this . pinnedRecordsCount ;
2679
+ rowIndex = rowIndex + this . pinnedDataView . length ;
2674
2680
}
2675
2681
return rowIndex ;
2676
2682
}
@@ -2727,6 +2733,15 @@ export class IgxGridBaseDirective extends DisplayDensityBase implements
2727
2733
return this . _pinnedRecordIDs . indexOf ( id ) !== - 1 ;
2728
2734
}
2729
2735
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
+
2730
2745
/**
2731
2746
* @hidden
2732
2747
* @internal
@@ -2997,6 +3012,7 @@ export class IgxGridBaseDirective extends DisplayDensityBase implements
2997
3012
data = data . map ( rec => rec . ghostRecord !== undefined ? rec . recordRef : rec ) ;
2998
3013
if ( this . _pinnedRecordIDs . length > 0 && pinned ) {
2999
3014
this . _filteredSortedPinnedData = data ;
3015
+ this . pinnedRecords = data ;
3000
3016
this . filteredSortedData = this . isRowPinningToTop ? [ ... this . _filteredSortedPinnedData , ... this . _filteredSortedUnpinnedData ] :
3001
3017
[ ... this . _filteredSortedUnpinnedData , ... this . _filteredSortedPinnedData ] ;
3002
3018
} else if ( this . _pinnedRecordIDs . length > 0 && ! pinned ) {
@@ -5172,25 +5188,38 @@ export class IgxGridBaseDirective extends DisplayDensityBase implements
5172
5188
}
5173
5189
5174
5190
/**
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.
5176
5192
* @example
5177
5193
* ```typescript
5178
- * const dataView = this.grid.dataView ;
5194
+ * const pinnedDataView = this.grid.pinnedDataView ;
5179
5195
* ```
5180
5196
*/
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 [ ] {
5182
5209
return this . unpinnedRecords ? this . unpinnedRecords : this . verticalScrollContainer . igxForOf ;
5183
5210
}
5184
5211
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 ] ;
5194
5223
}
5195
5224
5196
5225
/**
@@ -5433,7 +5462,7 @@ export class IgxGridBaseDirective extends DisplayDensityBase implements
5433
5462
* If `headers` is enabled, it will use the column header (if any) instead of the column field.
5434
5463
*/
5435
5464
public getSelectedData ( formatters = false , headers = false ) {
5436
- const source = this . isRowPinningToTop ? [ ... this . pinnedDataView , ... this . dataView ] : [ ... this . dataView , ... this . pinnedDataView ] ;
5465
+ const source = this . filteredSortedData ;
5437
5466
return this . extractDataFromSelection ( source , formatters , headers ) ;
5438
5467
}
5439
5468
@@ -5637,6 +5666,7 @@ export class IgxGridBaseDirective extends DisplayDensityBase implements
5637
5666
if ( this . dataView . slice ( rowIndex , rowIndex + 1 ) . find ( rec => rec . expression || rec . childGridsData ) ) {
5638
5667
visibleColIndex = - 1 ;
5639
5668
}
5669
+ // If the target row is pinned no need to scroll as well.
5640
5670
const shouldScrollVertically = this . navigation . shouldPerformVerticalScroll ( rowIndex , visibleColIndex ) ;
5641
5671
const shouldScrollHorizontally = this . navigation . shouldPerformHorizontalScroll ( visibleColIndex , rowIndex ) ;
5642
5672
if ( shouldScrollVertically ) {
@@ -5923,11 +5953,11 @@ export class IgxGridBaseDirective extends DisplayDensityBase implements
5923
5953
if ( delayScrolling ) {
5924
5954
this . verticalScrollContainer . onDataChanged . pipe ( first ( ) ) . subscribe ( ( ) => {
5925
5955
this . scrollDirective ( this . verticalScrollContainer ,
5926
- typeof ( row ) === 'number' ? row : this . dataView . indexOf ( row ) ) ;
5956
+ typeof ( row ) === 'number' ? row : this . unpinnedDataView . indexOf ( row ) ) ;
5927
5957
} ) ;
5928
5958
} else {
5929
5959
this . scrollDirective ( this . verticalScrollContainer ,
5930
- typeof ( row ) === 'number' ? row : this . dataView . indexOf ( row ) ) ;
5960
+ typeof ( row ) === 'number' ? row : this . unpinnedDataView . indexOf ( row ) ) ;
5931
5961
}
5932
5962
5933
5963
this . scrollToHorizontally ( column ) ;
0 commit comments