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

3 posts, 1 answers
  1. Andrew
    Andrew avatar
    2 posts
    Member since:
    Feb 2018

    Posted 18 Oct 2018 Link to this post

    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. Answer
    Alex Hajigeorgieva
    Admin
    Alex Hajigeorgieva avatar
    1082 posts

    Posted 19 Oct 2018 Link to this post

    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.
  3. Andrew
    Andrew avatar
    2 posts
    Member since:
    Feb 2018

    Posted 19 Oct 2018 in reply to Alex Hajigeorgieva Link to this post

    Thanks for the helpful answer. The custom delete confirmation dialog seems to work just fine.
Back to Top