user8643848
user8643848

Reputation:

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

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?

Upvotes: 3

Views: 5875

Answers (1)

DontVoteMeDown
DontVoteMeDown

Reputation: 21475

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

Upvotes: 5

Related Questions