Kendo Grid add new record event,how to catch it?

Viewed 4700

In kendo grid add new record has a event as following:

 if (e.model.isNew())

but for this I have to write it inside "edit:",is there any other function or way I can use it outside of grid scope?

1 Answers

You can always bind the edit event after the initialization and handle the create there. Note that the documentation says the edit event handles both create and edit, so there is no create event in the widget, only edit:

function grid_edit(e) {
  if (!e.model.isNew()) {
    // Disable the editor of the "id" column when editing data items
    var numeric = e.container.find("input[name=id]").data("kendoNumericTextBox");
    numeric.enable(false);
  }
}

$("#grid").data("kendoGrid").bind("edit", grid_edit);

Demo

Related