Reproduction
- Use a grid with data coming from a service (or another source)
- Click the delete button (built in with the grid
It removes the element from the grid as soon as I click the button but I want to remove it only after confirming the deletion.
Hi Moussa,
Thank you for your feedback.
In general, when the user clicks on the 'Remove' button the removeHandler function is invoked. A possible approach is to use the Angular Service of the Dialog component to show a confirmation dialog when the remove event is fired. Depending on the returned result the row can be removed:
public removeHandler({ dataItem }) {
const dialog: DialogRef = this.dialogService.open({
title: "Please confirm",
content: this.template,
actions: [{ text: "No" }, { text: "Yes", primary: true }],
width: 450,
height: 200,
minWidth: 250
});
dialog.result.subscribe((result: any) => {
if (result.text === "Yes") {
this.editService.remove(dataItem);
}
});
}
Please check the following StackBlitz which demonstrate the suggestion:
https://stackblitz.com/edit/angular-wnhpmh?file=app%2Fapp.component.ts
I hope this helps. Let me know if I can assist any further.
Regards,
Martin
Progress Telerik