Skip to content

Commit

Permalink
Merge pull request #10320 from IgniteUI/dTsvetkov/fix-10172-12.2
Browse files Browse the repository at this point in the history
fix(grid): fix getCellByColumn with virtualization #10172
  • Loading branch information
Lipata authored Oct 20, 2021
2 parents ebf3867 + 25f809b commit 35ce159
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -251,10 +251,16 @@ export class IgxGridNavigationService {
}

public isDataRow(rowIndex: number, includeSummary = false) {
let curRow: any;

if (rowIndex < 0 || rowIndex > this.grid.dataView.length - 1) {
return false;
curRow = this.grid.dataView[rowIndex - this.grid.virtualizationState.startIndex];
if (!curRow){
return false;
}
} else {
curRow = this.grid.dataView[rowIndex];
}
const curRow = this.grid.dataView[rowIndex];
return curRow && !this.grid.isGroupByRecord(curRow) && !this.grid.isDetailRecord(curRow)
&& !curRow.childGridsData && (includeSummary || !curRow.summaries);
}
Expand Down
12 changes: 10 additions & 2 deletions projects/igniteui-angular/src/lib/grids/grid/grid.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1029,7 +1029,7 @@ export class IgxGridComponent extends IgxGridBaseDirective implements GridType,
* @param index
*/
public getRowByIndex(index: number): RowType {
if (index < 0 || index >= this.dataView.length) {
if (index < 0) {
return undefined;
}
return this.createRow(index);
Expand Down Expand Up @@ -1140,8 +1140,16 @@ export class IgxGridComponent extends IgxGridBaseDirective implements GridType,
*/
public createRow(index: number, data?: any): RowType {
let row: RowType;
let rec: any;

const rec: any = data ?? this.dataView[index];
if (index < 0 || index >= this.dataView.length) {
if (index >= this.dataView.length){
const virtIndex = index - this.gridAPI.grid.virtualizationState.startIndex;
rec = data ?? this.dataView[virtIndex];
}
} else {
rec = data ?? this.dataView[index];
}

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

0 comments on commit 35ce159

Please sign in to comment.