Skip to content

Commit bb422f8

Browse files
authored
Merge pull request #10225 from IgniteUI/dTsvetkov/fix-10172-master
fix(grid): fix getCellByColumn with virtualization #10172 -master
2 parents a5574f8 + a97e687 commit bb422f8

File tree

2 files changed

+18
-4
lines changed

2 files changed

+18
-4
lines changed

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

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -251,10 +251,16 @@ export class IgxGridNavigationService {
251251
}
252252

253253
public isDataRow(rowIndex: number, includeSummary = false) {
254+
let curRow: any;
255+
254256
if (rowIndex < 0 || rowIndex > this.grid.dataView.length - 1) {
255-
return false;
257+
curRow = this.grid.dataView[rowIndex - this.grid.virtualizationState.startIndex];
258+
if (!curRow){
259+
return false;
260+
}
261+
}else {
262+
curRow = this.grid.dataView[rowIndex];
256263
}
257-
const curRow = this.grid.dataView[rowIndex];
258264
return curRow && !this.grid.isGroupByRecord(curRow) && !this.grid.isDetailRecord(curRow)
259265
&& !curRow.childGridsData && (includeSummary || !curRow.summaries);
260266
}

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

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1029,7 +1029,7 @@ export class IgxGridComponent extends IgxGridBaseDirective implements GridType,
10291029
* @param index
10301030
*/
10311031
public getRowByIndex(index: number): RowType {
1032-
if (index < 0 || index >= this.dataView.length) {
1032+
if (index < 0) {
10331033
return undefined;
10341034
}
10351035
return this.createRow(index);
@@ -1140,8 +1140,16 @@ export class IgxGridComponent extends IgxGridBaseDirective implements GridType,
11401140
*/
11411141
public createRow(index: number, data?: any): RowType {
11421142
let row: RowType;
1143+
let rec: any;
11431144

1144-
const rec: any = data ?? this.dataView[index];
1145+
if (index < 0 || index >= this.dataView.length) {
1146+
if (index >= this.dataView.length){
1147+
const virtIndex = index - this.gridAPI.grid.virtualizationState.startIndex;
1148+
rec = data ?? this.dataView[virtIndex];
1149+
}
1150+
}else {
1151+
rec = data ?? this.dataView[index];
1152+
}
11451153

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

0 commit comments

Comments
 (0)