This is a migrated thread and some comments may be shown as answers.

Confiramtion on delete

1 Answer 120 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
Faris
Top achievements
Rank 1
Faris asked on 30 Sep 2020, 07:02 AM
How to add confirmation dialogue while deleting a node from tree?

1 Answer, 1 is accepted

Sort by
1
Accepted
Hetali
Telerik team
answered on 01 Oct 2020, 05:59 PM

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/.

Tags
TreeView
Asked by
Faris
Top achievements
Rank 1
Answers by
Hetali
Telerik team
Share this question
or