Skip to content

Commit 229bcd1

Browse files
MKirovaMKirova
authored andcommitted
chore(*): Adjust indexes when there are pinned rows to top.
1 parent 5ab08a8 commit 229bcd1

File tree

7 files changed

+24
-16
lines changed

7 files changed

+24
-16
lines changed

projects/igniteui-angular/src/lib/grids/grid-base.directive.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3697,7 +3697,7 @@ export abstract class IgxGridBaseDirective implements GridType,
36973697
}
36983698

36993699
protected getMergeCellOffset(rowData) {
3700-
const index = rowData.index;
3700+
const index = rowData.dataIndex;
37013701
let offset = this.verticalScrollContainer.scrollPosition - this.verticalScrollContainer.getScrollForIndex(index);
37023702
if (this.hasPinnedRecords && this.isRowPinningToTop) {
37033703
offset -= this.pinnedRowHeight;
@@ -3892,7 +3892,8 @@ export abstract class IgxGridBaseDirective implements GridType,
38923892
if (rec.cellMergeMeta &&
38933893
// index + maxRowSpan is within view
38943894
startIndex < (index + Math.max(...rec.cellMergeMeta.values().toArray().map(x => x.rowSpan)))) {
3895-
data.push({record: rec, index: index });
3895+
const visibleIndex = this.isRowPinningToTop ? index + this.pinnedRecordsCount : index;
3896+
data.push({record: rec, index: visibleIndex, dataIndex: index });
38963897
}
38973898
}
38983899
this._mergedDataInView = data;

projects/igniteui-angular/src/lib/grids/grid/grid.component.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@
6363
| gridRowPinning:id:true:pipeTrigger
6464
| gridFiltering:filteringExpressionsTree:filterStrategy:advancedFilteringExpressionsTree:id:pipeTrigger:filteringPipeTrigger:true
6565
| gridSort:sortingExpressions:groupingExpressions:sortStrategy:id:pipeTrigger:true
66-
| gridCellMerge:visibleColumns:cellMergeMode:sortingExpressions:activeRowIndexes:pipeTrigger; as pinnedData) {
66+
| gridCellMerge:visibleColumns:cellMergeMode:sortingExpressions:activeRowIndexes:true:pipeTrigger; as pinnedData) {
6767
@if (pinnedData.length > 0) {
6868
<div #pinContainer
6969
[ngClass]="{
@@ -90,7 +90,7 @@
9090
| gridDetails:hasDetails:expansionStates:pipeTrigger
9191
| gridAddRow:false:pipeTrigger
9292
| gridRowPinning:id:false:pipeTrigger
93-
| gridCellMerge:visibleColumns:cellMergeMode:sortingExpressions:activeRowIndexes:pipeTrigger"
93+
| gridCellMerge:visibleColumns:cellMergeMode:sortingExpressions:activeRowIndexes:false:pipeTrigger"
9494
let-rowIndex="index" [igxForScrollOrientation]="'vertical'" [igxForScrollContainer]="verticalScroll"
9595
[igxForContainerSize]="calcHeight"
9696
[igxForItemSize]="hasColumnLayouts ? rowHeight * multiRowLayoutRowSize + 1 : renderedRowHeight"

projects/igniteui-angular/src/lib/grids/grid/grid.pipes.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,11 +85,14 @@ export class IgxGridCellMergePipe implements PipeTransform {
8585

8686
constructor(@Inject(IGX_GRID_BASE) private grid: GridType) { }
8787

88-
public transform(collection: any, visibleColumns: ColumnType[], mergeMode: GridCellMergeMode, sortExpr: ISortingExpression[], activeRowIndexes: number[], _pipeTrigger: number) {
88+
public transform(collection: any, visibleColumns: ColumnType[], mergeMode: GridCellMergeMode, sortExpr: ISortingExpression[], activeRowIndexes: number[], pinned: boolean, _pipeTrigger: number) {
8989
const colsToMerge = this.grid.columnsToMerge;
90-
if (colsToMerge.length=== 0) {
90+
if (colsToMerge.length === 0) {
9191
return collection;
9292
}
93+
if (!pinned && this.grid.isPinningToStart) {
94+
activeRowIndexes = activeRowIndexes.map(x => x - this.grid.pinnedRecordsCount);
95+
}
9396
const result = DataUtil.merge(cloneArray(collection), colsToMerge, this.grid.mergeStrategy, activeRowIndexes, this.grid);
9497
return result;
9598
}

projects/igniteui-angular/src/lib/grids/hierarchical-grid/hierarchical-grid.component.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@
4646
| gridRowPinning:id:true:pipeTrigger
4747
| gridFiltering:filteringExpressionsTree:filterStrategy:advancedFilteringExpressionsTree:id:pipeTrigger:filteringPipeTrigger:true
4848
| gridSort:sortingExpressions:[]:sortStrategy:id:pipeTrigger:true
49-
| gridCellMerge:visibleColumns:cellMergeMode:sortingExpressions:activeRowIndexes:pipeTrigger; as pinnedData
49+
| gridCellMerge:visibleColumns:cellMergeMode:sortingExpressions:activeRowIndexes:true:pipeTrigger; as pinnedData
5050
) {
5151
@if (pinnedData.length > 0) {
5252
<div #pinContainer class="igx-grid__tr--pinned"
@@ -71,7 +71,7 @@
7171
| gridHierarchical:expansionStates:id:primaryKey:childLayoutKeys:pipeTrigger
7272
| gridAddRow:false:pipeTrigger
7373
| gridRowPinning:id:false:pipeTrigger
74-
| gridCellMerge:visibleColumns:cellMergeMode:sortingExpressions:activeRowIndexes:pipeTrigger"
74+
| gridCellMerge:visibleColumns:cellMergeMode:sortingExpressions:activeRowIndexes:false:pipeTrigger"
7575
[igxForScrollOrientation]="'vertical'" [igxForScrollContainer]="verticalScroll"
7676
[igxForContainerSize]="calcHeight" [igxForItemSize]="renderedRowHeight" [igxForTrackBy]="trackChanges"
7777
#verticalScrollContainer (chunkPreload)="dataLoading($event)" (dataChanging)="dataRebinding($event)" (dataChanged)="dataRebound($event)">

projects/igniteui-angular/src/lib/grids/tree-grid/tree-grid.component.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@
4747
| gridRowPinning:id:true:pipeTrigger
4848
| treeGridFiltering:filteringExpressionsTree:filterStrategy:advancedFilteringExpressionsTree:pipeTrigger:filteringPipeTrigger:true
4949
| treeGridSorting:sortingExpressions:treeGroupArea?.expressions:sortStrategy:pipeTrigger:true
50-
| gridCellMerge:visibleColumns:cellMergeMode:sortingExpressions:activeRowIndexes:pipeTrigger; as pinnedData
50+
| gridCellMerge:visibleColumns:cellMergeMode:sortingExpressions:activeRowIndexes:true:pipeTrigger; as pinnedData
5151
) {
5252
@if (pinnedData.length > 0) {
5353
<div #pinContainer
@@ -76,7 +76,7 @@
7676
| treeGridSummary:hasSummarizedColumns:summaryCalculationMode:summaryPosition:showSummaryOnCollapse:pipeTrigger:summaryPipeTrigger
7777
| treeGridAddRow:false:pipeTrigger
7878
| gridRowPinning:id:false:pipeTrigger
79-
| gridCellMerge:visibleColumns:cellMergeMode:sortingExpressions:activeRowIndexes:pipeTrigger"
79+
| gridCellMerge:visibleColumns:cellMergeMode:sortingExpressions:activeRowIndexes:false:pipeTrigger"
8080
let-rowIndex="index" [igxForScrollOrientation]="'vertical'" [igxForScrollContainer]='verticalScroll'
8181
[igxForContainerSize]='calcHeight' [igxForItemSize]="renderedRowHeight" #verticalScrollContainer
8282
(dataChanging)="dataRebinding($event)" (dataChanged)="dataRebound($event)">

src/app/grid-cellMerging/grid-cellMerging.component.html

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,10 @@ <h4 class="sample-title">Grid with cell merge</h4>
4545
</div>
4646
<igx-grid [data]="data" width="800px" height="550px" [moving]="true" #grid1
4747
[cellMergeMode]="'always'" [rowSelection]="'single'">
48-
<igx-column field="OrderID" header="Order ID" [hidden]="true" >
48+
<igx-column field="OrderID" header="Order ID">
49+
<ng-template igxCell let-cell="cell" let-val>
50+
Value: {{val}},Index: {{cell.row.index}}
51+
</ng-template>
4952
</igx-column>
5053
<igx-column field="ShipCountry" header="Ship Country" width="200px" [merge]="true" sortable="true">
5154
</igx-column>
@@ -69,9 +72,9 @@ <h4 class="sample-title">Grid with cell merge</h4>
6972
</igx-column>
7073
<igx-paginator [perPage]="20">
7174
</igx-paginator>
72-
<!-- <igx-action-strip>
75+
<igx-action-strip>
7376
<igx-grid-pinning-actions></igx-grid-pinning-actions>
74-
</igx-action-strip> -->
77+
</igx-action-strip>
7578
<igx-grid-toolbar>
7679
<igx-grid-toolbar-actions>
7780
<igx-grid-toolbar-hiding></igx-grid-toolbar-hiding>

src/app/grid-cellMerging/grid-cellMerging.component.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@ import { INVOICE_DATA } from '../shared/invoiceData';
3838
IgxColumnComponent,
3939
IgxGridComponent,
4040
IgxPaginatorComponent,
41-
// IgxActionStripComponent,
42-
// IgxGridPinningActionsComponent,
41+
IgxActionStripComponent,
42+
IgxGridPinningActionsComponent,
4343
IgxGridToolbarComponent,
4444
IgxGridToolbarActionsComponent,
4545
IgxGridToolbarPinningComponent,
@@ -51,7 +51,8 @@ import { INVOICE_DATA } from '../shared/invoiceData';
5151
IgxPrefixDirective,
5252
IgxSuffixDirective,
5353
IgxIconComponent,
54-
IgxInputDirective
54+
IgxInputDirective,
55+
IgxCellTemplateDirective
5556
]
5657
})
5758
export class GridCellMergingComponent {

0 commit comments

Comments
 (0)