We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

how i can show confirmation when click close button edit dialog

how i can show confirmation when click close button edit dialog





1 Reply

RS Rajapandiyan Settu Syncfusion Team December 14, 2022 10:07 AM UTC

Hi Apisit,


Thanks for contacting Syncfusion support.


In EJ2 Grid, the confirmation popup is not shown when clicking the cancel button in the Edit Dialog. You can achieve your requirement by manually showing the custom confirmation popup.


In the actionBegin event (requestType as cancel), we prevented the default action of cancel and showed the custom confirmation popup based on the flag variable.


actionBegin: https://ej2.syncfusion.com/angular/documentation/api/grid/#actionbegin

actionComplete: https://ej2.syncfusion.com/angular/documentation/api/grid/#actioncomplete

 

[app.component.html]

// custom confirm dialog
  <ejs-dialog

    id="modalDialog"

    #modalDialog

    [visible]="false"

    [isModal]="isModal"

    [target]="target"

    [width]="width"

    [buttons]="buttons"

    [content]="content"

  >

  </ejs-dialog>

 

 

[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

    }

  }

}

 


Sample: https://stackblitz.com/edit/angular-mpd7dt-aqjf65?file=app.component.html,app.component.ts

Regards, 

Rajapandiyan S


Loader.
Live Chat Icon For mobile
Up arrow icon