0
votes

How to prevent the Kendo MVC Grid Buttons event.Like

Save button , Cancel button.

I am working on ASP.NET MVC4 application with Kendo MVC controls.

I want to do that on onchange event of Kendo Grid.Below is my code for onchange function calling:

.Events(events => events.Change("onChange"))

And in which i want to prevent the Save and Cancel button events in case of firing any validation on onchange event.

Below is the code of my onchange event:

function onChange(arg) {
    $(".k-button.k-button-icontext.k-grid-add").html("<span class=\"k-icon k-add\"></span>Add New Media");
    if (!arg.action) {
        $(".k-button.k-button-icontext.k-grid-save-changes").hide();
        $(".k-button.k-button-icontext.k-grid-cancel-changes").hide();
        $("#gridkendo").show();
    } else {
        if (arg.items[0].Name) {
        }
    }
}

I want to prevent the Kendo grid's buttons on onchange event function else condition.

FYI,i am using argument in onchange event function argument.

1

1 Answers

-1
votes

On the first line of your onChange function use preventDefault on the event.

function onChange(arg) { 
   arg.stopImmediatePropagation();
   // rest of your code
}

Have a look at the documentation https://api.jquery.com/event.stopimmediatepropagation/ The work that usually happens on a grid change event, will not.