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

requestStart: preventDefault doesn't work for 'destroy' event

2 Answers 377 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Andrew
Top achievements
Rank 1
Andrew asked on 18 Oct 2018, 08:10 PM

Hello,

I'm trying to stop a "destroy" request in order to insert a custom confirmation dialog. According to the documentation (https://docs.telerik.com/kendo-ui/api/javascript/data/datasource/events/requeststart), this should be possible by calling "e.preventDefault()".

This works to prevent the request for certain types of requests such as "read", but not for "destroy". Please see this example: http://dojo.telerik.com/OmOdOcuH

Note in the developer console that the request is still made when a row is deleted despite calling "e.preventDefault()".

Is this behavior intentional or a bug? Is there a workaround?

Thanks for your help.

2 Answers, 1 is accepted

Sort by
0
Accepted
Alex Hajigeorgieva
Telerik team
answered on 19 Oct 2018, 12:27 PM
Hello, Andrew,

The requestStart event of the Kendo UI Data Source can only be prevented for "read" requests as outlined in the important box in the documentation:

https://docs.telerik.com/kendo-ui/api/javascript/data/datasource/events/requeststart

To get a custom confirmation message for the destroy operation of the Kendo UI Grid, why not take advantage of the editable.confirmation configuration option:

https://docs.telerik.com/kendo-ui/api/javascript/ui/grid/configuration/editable.confirmation

Here is the updated example:

http://dojo.telerik.com/@bubblemaster/IpOfavay

editable: {
  mode: "inline",
  confirmation: function(e) {
    return  "Are you sure that you want to delete\n " + e.ProductName + "?";
  }
}

If the level of customization is not enough, you can follow  the How-to article to create an entirely custom confirmation window:

https://docs.telerik.com/kendo-ui/controls/data-management/grid/how-to/Editing/custom-delete-confirmation-dialog

Let me know in case you have any further questions.

Kind Regards,
Alex Hajigeorgieva
Progress Telerik
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
0
Andrew
Top achievements
Rank 1
answered on 19 Oct 2018, 02:41 PM
Thanks for the helpful answer. The custom delete confirmation dialog seems to work just fine.
Tags
Grid
Asked by
Andrew
Top achievements
Rank 1
Answers by
Alex Hajigeorgieva
Telerik team
Andrew
Top achievements
Rank 1
Share this question
or