[app.component.ts]
export class AppComponent {
@ViewChild('modalDialog')
public confirmDialog: DialogComponent;
// Close the Edit
Dialog, while clicking "OK" Button
public dlgOKClick = (): void => {
this.confirmDialog.hide();
this.flag = false;
this.grid.closeEdit();
};
// maintain the Edit
Dialog
public dlgNOClick = (): void => {
this.flag = true;
this.confirmDialog.hide();
};
public buttons: { [key: string]: ButtonModel }[] = [
{
click: this.dlgOKClick.bind(this),
buttonModel: { content: 'OK', isPrimary: true },
},
{
click: this.dlgNOClick.bind(this),
buttonModel: { content: 'Cancel' },
},
];
actionBegin(args) {
if (args.requestType == 'cancel' && this.flag) {
args.cancel = true;
// prevent the default cancel action
this.confirmDialog.show();
// show the custom confirm dialog
}
}
actionComplete(args) {
if (args.requestType == 'cancel') {
this.flag = true;
// make the flag variable true
}
}
}
|