Confiramtion on delete

2 posts, 1 answers
  1. Faris
    Faris avatar
    3 posts
    Member since:
    Sep 2018

    Posted 30 Sep Link to this post

    How to add confirmation dialogue while deleting a node from tree?
  2. Answer
    Hetali
    Admin
    Hetali avatar
    60 posts

    Posted 01 Oct Link to this post

    Hi Faris,

    In order to add a confirmation dialog before deleting a node, use the DialogService to dynamically create a dialog box during the delete event. For example:

    constructor( private dialogService: DialogService ) {}
    
    deleteEvent() {
      const dialog: DialogRef = this.dialogService.open({
        title: 'Please confirm',
        content: 'Are you sure you want to delete?',
        actions: [
          { text: 'No' },
          { text: 'Yes', primary: true }
        ],
        width: 450,
        height: 200,
        minWidth: 250
      });
    
      dialog.result.subscribe((result) => {
        if (result instanceof DialogCloseResult) {
          console.log('close');
        } else {
          console.log('action', result);
        }
    
        this.result = JSON.stringify(result);
      });
    }

    If the above solution does not work, could you please respond with your code or a StackBlitz example? I will further help you.

    Please give it a try and let me know if it helps. 

    Regards,
    Hetali
    Progress Telerik

    Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

Back to Top