beforeEdit

Fires when the user tries to edit or creates a data item before the editor is created. Can be used for preventing the editing depending on custom logic. The event handler function context (available through the this keyword) will be set to the widget instance. The event will be fired only when the TreeList is editable.

Event Data

e.model kendo.data.Model

The data item which will be edited. To check if the data item is new (created) or not (edited), use its isNew method.

e.sender kendo.ui.TreeList

The widget instance which fired the event.

Example - subscribing to the beforeEdit event during initialization

<div id="treeList"></div>
<script>
  $("#treeList").kendoTreeList({
    columns: [
      { field: "name" },
      { field: "age" }
    ],
    dataSource: [
      { id: 1, parentId: null, name: "Jane Doe", age: 22, expanded: true },
      { id: 2, parentId: 1, name: "John Doe", age: 24 },
      { id: 3, parentId: 1, name: "Jenny Doe", age: 3 }
    ],
    editable: "incell",
    toolbar:["create"],
    beforeEdit: function(e) {
/* The result can be observed in the DevTools(F12) console of the browser. */
      console.log("beforeEdit");

      if (!e.model.isNew()) {
        e.preventDefault();
      }
    }
  });
</script>
In this article