How to trap cancel event in incell(batch) mode

5 posts, 1 answers
  1. Jon Smith
    Jon Smith avatar
    3 posts
    Member since:
    Aug 2018

    Posted 22 Nov 2018 Link to this post

    I have added the cancel event to my grid as follows:

    .Events(e => e.Cancel("onCancel")

    .......

    function onCancel(e) {

    ......

    }

    However the function is not being called when I click "Cancel Changes".  According to the documentation, the Cancel event is only fired in the other two edit modes.  How is it possible to trap the clicking of this button in the toolbar?

    Many thanks,

    Colin

  2. Jon Smith
    Jon Smith avatar
    3 posts
    Member since:
    Aug 2018

    Posted 22 Nov 2018 in reply to Jon Smith Link to this post

    Actually, disregard that (unless there is a better answer) as I can just trap the DataBound event which is called anyway on cancel.
  3. Answer
    Viktor Tachev
    Admin
    Viktor Tachev avatar
    2497 posts

    Posted 23 Nov 2018 Link to this post

    Hi Colin,

    Pressing the cancel button in the toolbar will trigger the cancelChanges method internally. In turn the dataBound event will be raised for the Grid. 

    Another approach you can use if you would like to execute additional logic when the button is clicked is to manually add a handler for the mousedown event of the button. Like this:

    $(".k-grid-cancel-changes").on("mousedown", function(e) {
        console.log("cancelling changes");
    });

    Let me know how this approach works for you.

    Regards,
    Viktor Tachev
    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.
  4. Antony
    Antony avatar
    15 posts
    Member since:
    Jan 2012

    Posted 06 Jan 2020 in reply to Viktor Tachev Link to this post

    I had an unexpected side-effect: the Cancel button stopped making the deleted rows visible again. This was the code that caused the problem (I've just included the onDelete function below to show why I need to handle the Cancel event):

    function onDelete(e) {
        $("#msg").append(" " + e.model.LastName + " will be removed when you Save");
    }
     
    $(".k-grid-cancel-changes").on("mousedown", function (e) {
        $("#msg").text("");
    });

     

    To make Cancel changes work again I had to change the mousedown function to:

    $(".k-grid-cancel-changes").on("mousedown", function (e) {
        var grid = $("#EmployeeGrid").data("kendoGrid");
        grid.cancelChanges();
        $("#msg").text("");
    });
  5. Viktor Tachev
    Admin
    Viktor Tachev avatar
    2497 posts

    Posted 08 Jan 2020 Link to this post

    Hi Anthony,

     

    Would you send a dojo sample where the behavior you are seeing is replicated? This will enable us to examine the issue and look for its cause.

     

    Regards,
    Viktor Tachev
    Progress Telerik

    Get quickly onboarded and successful with your Telerik UI for ASP.NET MVC with the dedicated Virtual Classroom technical training, available to all active customers.
Back to Top