Skip to content

Commit

Permalink
refactor(grid): add comment to row delete+paging, change check for pa…
Browse files Browse the repository at this point in the history
…ge, #3425
  • Loading branch information
ViktorSlavov committed Dec 18, 2018
1 parent d131907 commit 6fb8380
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions projects/igniteui-angular/src/lib/grids/grid-base.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3049,7 +3049,7 @@ export abstract class IgxGridBaseComponent extends DisplayDensityBase implements
/** @hidden */
public deleteRowById(rowId: any) {
let index: number;
const data = this.gridAPI.get_all_data(this.id, this.transactions.enabled);
const data = this.gridAPI.get_all_data(this.id);
if (this.primaryKey) {
index = data.map((record) => record[this.primaryKey]).indexOf(rowId);
} else {
Expand Down Expand Up @@ -3081,13 +3081,12 @@ export abstract class IgxGridBaseComponent extends DisplayDensityBase implements
this.deleteRowFromData(rowId, index);
this._pipeTrigger++;
this.cdr.markForCheck();
const dataAfterDelete = !this.transactions.enabled ? data : this.dataWithAddedInTransactionRows;
// Data needs to be recalculated if transactions are in place
// If no transactions, `data` will be a reference to the grid getter, otherwise it will be stale
const dataAfterDelete = this.transactions.enabled ? this.dataWithAddedInTransactionRows : data;
this.refreshSearch();
if (dataAfterDelete.length % this.perPage === 0 && this.isLastPage && this.page !== 0) {
const currentPage = Math.ceil(dataAfterDelete.length / this.perPage) - 1;
if (this.page !== currentPage) {
this.page = currentPage;
}
if (dataAfterDelete.length % this.perPage === 0 && dataAfterDelete.length / this.perPage - 1 < this.page && this.page !== 0) {
this.page--;
}
}

Expand Down

0 comments on commit 6fb8380

Please sign in to comment.