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

How to trap cancel event in incell(batch) mode

4 Answers 59 Views
This is a migrated thread and some comments may be shown as answers.
n/a
Top achievements
Rank 1
n/a asked on 22 Nov 2018, 03:00 PM

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

4 Answers, 1 is accepted

Sort by
0
n/a
Top achievements
Rank 1
answered on 22 Nov 2018, 03:05 PM
Actually, disregard that (unless there is a better answer) as I can just trap the DataBound event which is called anyway on cancel.
0
Accepted
Viktor Tachev
Telerik team
answered on 23 Nov 2018, 11:00 AM
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.
0
Antony
Top achievements
Rank 1
Iron
answered on 06 Jan 2020, 11:11 PM

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("");
});
0
Viktor Tachev
Telerik team
answered on 08 Jan 2020, 12:13 PM

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.
Tags
Grid
Asked by
n/a
Top achievements
Rank 1
Answers by
n/a
Top achievements
Rank 1
Viktor Tachev
Telerik team
Antony
Top achievements
Rank 1
Iron
Share this question
or