Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 10 additions & 6 deletions projects/igniteui-angular/src/lib/grids/grid-base.directive.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5964,18 +5964,22 @@ export abstract class IgxGridBaseDirective extends DisplayDensityBase implements
console.warn('The record cannot be added as a child to an unspecified record.');
return;
}
index = 0;
index = null;
} else {
// find the index of the record with that PK
index = this.gridAPI.get_rec_index_by_id(rowID, this.dataView);
rowID = index;
if (index === -1) {
console.warn('No row with the specified ID was found.');
return;
}
}

this._addRowForIndex(index, asChild);
}

protected _addRowForIndex(index: number, asChild?: boolean) {
if (!this.dataView.length) {
this.beginAddRowForIndex(rowID, asChild);
this.beginAddRowForIndex(index, asChild);
return;
}
// check if the index is valid - won't support anything outside the data view
Expand All @@ -5987,13 +5991,13 @@ export abstract class IgxGridBaseDirective extends DisplayDensityBase implements
this.verticalScrollContainer.chunkLoad
.pipe(first(), takeUntil(this.destroy$))
.subscribe(() => {
this.beginAddRowForIndex(rowID, asChild);
this.beginAddRowForIndex(index, asChild);
});
this.navigateTo(index);
this.notifyChanges(true);
return;
}
this.beginAddRowForIndex(rowID, asChild);
this.beginAddRowForIndex(index, asChild);
} else {
console.warn('The row with the specified PK or index is outside of the current data view.');
}
Expand All @@ -6014,7 +6018,7 @@ export abstract class IgxGridBaseDirective extends DisplayDensityBase implements
if (index === 0) {
return this.beginAddRowById(null);
}
return this.beginAddRowById(this.gridAPI.get_rec_id_by_index(index - 1, this.dataView));
return this._addRowForIndex(index - 1);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -633,7 +633,7 @@ export class IgxTreeGridComponent extends IgxGridBaseDirective implements GridTy
if (index === null || index < 0) {
return this.beginAddRowById(null, asChild);
}
return this.beginAddRowById(this.gridAPI.get_rec_id_by_index(index, this.dataView), asChild);
return this._addRowForIndex(index - 1, asChild);
}

/**
Expand Down