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
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
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("");
});
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