Skip to content

Commit de2f318

Browse files
committed
chore(*): fix grid navigation with remote data
1 parent d2ca291 commit de2f318

File tree

2 files changed

+14
-7
lines changed

2 files changed

+14
-7
lines changed

projects/igniteui-angular/src/lib/grids/grid-navigation.service.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -248,10 +248,14 @@ export class IgxGridNavigationService {
248248
}
249249

250250
public isDataRow(rowIndex: number, includeSummary = false) {
251-
if (rowIndex < 0 || rowIndex > this.grid.dataView.length - 1) {
251+
let curRow: any;
252+
if (this.grid.virtualizationState) {
253+
curRow = this.grid.dataView[rowIndex - this.grid.virtualizationState.startIndex];
254+
}else if (rowIndex < 0 || rowIndex > this.grid.dataView.length - 1) {
252255
return false;
256+
}else {
257+
curRow = this.grid.dataView[rowIndex];
253258
}
254-
const curRow = this.grid.dataView[rowIndex];
255259
return curRow && !this.grid.isGroupByRecord(curRow) && !this.grid.isDetailRecord(curRow)
256260
&& !curRow.childGridsData && (includeSummary || !curRow.summaries);
257261
}

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

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1030,7 +1030,7 @@ export class IgxGridComponent extends IgxGridBaseDirective implements GridType,
10301030
*/
10311031
public getRowByIndex(index: number): RowType {
10321032
if (this.gridAPI.grid.virtualizationState){
1033-
index = index - this.gridAPI.grid.virtualizationState.startIndex;
1033+
return this.createRow(index);
10341034
}
10351035
if (index < 0 || index >= this.dataView.length) {
10361036
return undefined;
@@ -1104,9 +1104,6 @@ export class IgxGridComponent extends IgxGridBaseDirective implements GridType,
11041104
const row = this.getRowByIndex(rowIndex);
11051105
const column = this.columnList.find((col) => col.field === columnField);
11061106
if (row && row instanceof IgxGridRow && !row.data?.detailsData && column) {
1107-
if (this.gridAPI.grid.virtualizationState){
1108-
rowIndex = row.index;
1109-
}
11101107
return new IgxGridCell(this, rowIndex, columnField);
11111108
}
11121109
}
@@ -1146,8 +1143,14 @@ export class IgxGridComponent extends IgxGridBaseDirective implements GridType,
11461143
*/
11471144
public createRow(index: number, data?: any): RowType {
11481145
let row: RowType;
1146+
let rec: any;
11491147

1150-
const rec: any = data ?? this.dataView[index];
1148+
if (this.gridAPI.grid.virtualizationState) {
1149+
const virtIndex = index - this.gridAPI.grid.virtualizationState.startIndex;
1150+
rec = data ?? this.dataView[virtIndex];
1151+
}else {
1152+
rec = data ?? this.dataView[index];
1153+
}
11511154

11521155
if (rec && this.isGroupByRecord(rec)) {
11531156
row = new IgxGroupByRow(this, index, rec);

0 commit comments

Comments
 (0)