How to override the default update event in edit mode in KendoGrid mode

Is there a way to capture the update event that is dynamically generated in the inline editing mode. I tried using the edit and undo commands and it worked successfully. I went through this example and worked with the cancel command. Any help would be greatly appreciated.

enter image description here

enter image description here

+4
source share
1 answer

Depending on when exactly you want to intercept an event.

save. , inline.

- ( , save Events Grid):

@(Html.Kendo().Grid(Model).DataSource(dataSource => ...)
                          .Columns(columns => ...)
                          .Editable(editing => ...)
                          .Events(events => events.DataBound("onGridDataBound")
                                                  .Save("onGridSave")
                                                  .Edit("onGridEdit")
                                                  .Change("onGridChange")
                          )
            )

save ( JavaScript)

$(document).ready(function () {
  var crudServiceBaseUrl = "http://demos.telerik.com/kendo-ui/service",
      dataSource = new kendo.data.DataSource({
        transport: {
          read:  {
            url: crudServiceBaseUrl + "/Products",
            dataType: "jsonp"
          },
          update: {
            url: crudServiceBaseUrl + "/Products/Update",
            dataType: "jsonp"
          },
          destroy: {
            url: crudServiceBaseUrl + "/Products/Destroy",
            dataType: "jsonp"
          },
          create: {
            url: crudServiceBaseUrl + "/Products/Create",
            dataType: "jsonp"
          },
          parameterMap: function(options, operation) {
            if (operation !== "read" && options.models) {
              return {models: kendo.stringify(options.models)};
            }
          }
        },
        batch: true,
        pageSize: 20,
        schema: {
          model: {
            id: "ProductID",
            fields: {
              ProductID: { editable: false, nullable: true },
              ProductName: { validation: { required: true } },
              UnitPrice: { type: "number", validation: { required: true, min: 1} },
              Discontinued: { type: "boolean" },
              UnitsInStock: { type: "number", validation: { min: 0, required: true } }
            }
          }
        }
      });

  $("#grid").kendoGrid({
    dataSource: dataSource,
    pageable: true,
    height: 550,
    toolbar: ["create"],
    columns: [
      "ProductName",
      { field: "UnitPrice", title: "Unit Price", format: "{0:c}", width: "120px" },
      { field: "UnitsInStock", title:"Units In Stock", width: "120px" },
      { field: "Discontinued", width: "120px" },
      { command: ["edit", "destroy"], title: " ", width: "250px" }],
    editable: "inline",
    save: function(e) {
      alert("Saving");
    }
  });
});
<link rel="stylesheet" href="http://cdn.kendostatic.com/2014.3.1119/styles/kendo.common.min.css" />
<link rel="stylesheet" href="http://cdn.kendostatic.com/2014.3.1119/styles/kendo.default.min.css" />
<script src="http://cdn.kendostatic.com/2014.3.1119/js/jquery.min.js"></script>
<script src="http://cdn.kendostatic.com/2014.3.1119/js/kendo.all.min.js"></script>

<div id="grid"></div>
+5

All Articles