Skip to content

Commit

Permalink
fix(transaction): check for transactions when commiting delete, #3425
Browse files Browse the repository at this point in the history
  • Loading branch information
ViktorSlavov committed Dec 14, 2018
1 parent b6b6825 commit 3d09204
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions projects/igniteui-angular/src/lib/grids/grid-base.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2288,6 +2288,12 @@ export abstract class IgxGridBaseComponent extends DisplayDensityBase implements
this.summaryService.clearSummaryCache();
this._pipeTrigger++;
this.markForCheck();
if (this.transactions.getAggregatedChanges(false).length === 0) {
// Needs better check, calling 'transactions.clear()' will also trigger this
if (this.data.length % this.perPage === 0 && this.isLastPage && this.page !== 0) {
this.page--;
}
}
});
}

Expand Down Expand Up @@ -3072,13 +3078,22 @@ export abstract class IgxGridBaseComponent extends DisplayDensityBase implements
this.checkHeaderCheckboxStatus();
}

const addedRowsDif = this.dataWithAddedInTransactionRows.length - this.data.length;
this.deleteRowFromData(rowId, index);
this._pipeTrigger++;
this.cdr.markForCheck();

this.refreshSearch();
if (data.length % this.perPage === 0 && this.isLastPage && this.page !== 0) {
this.page--;
if (this.isLastPage && this.page !== 0) {
let pageSwitch = 0;
if (!this.transactions.enabled) {
pageSwitch = this.data.length % this.perPage === 0 ? 1 : 0;
} else {
if (addedRowsDif) {
pageSwitch = this.dataWithAddedInTransactionRows.length % this.perPage === 0 ? 1 : 0;
}
}
this.page -= pageSwitch;
}
}

Expand Down

0 comments on commit 3d09204

Please sign in to comment.