cancelEdit

Cancels edit and close the popup form.

Example - cancel edit conditionally

<button id="cancelBtn">Cancel Edit</button>
<div id="diagram"></div>
<script>
  function onEdit(e){
    if(e.shape){
      var shape = e.shape;
      if(shape.JobTitle == "President"){
        e.sender.cancelEdit();
      }
    }
  }

  var serviceRoot = "https://demos.telerik.com/kendo-ui/service";

  var shapesDataSource = {
    batch: false,
    transport: {
      read: {
        url: serviceRoot + "/DiagramShapes",
        dataType: "jsonp"
      },
      update: {
        url: serviceRoot + "/DiagramShapes/Update",
        dataType: "jsonp"
      },
      destroy: {
        url: serviceRoot + "/DiagramShapes/Destroy",
        dataType: "jsonp"
      },
      create: {
        url: serviceRoot + "/DiagramShapes/Create",
        dataType: "jsonp"
      },
      parameterMap: function (options, operation) {
        if (operation !== "read") {
          return { models: kendo.stringify(options.models || [options]) };
        }
      }
    },
    schema: {
      model: {
        id: "id",
        fields: {
          id: { from: "Id", type: "number", editable: false },
          JobTitle: { type: "string" },
          Color: { type: "string" }
        }
      }
    }
  };

  var connectionsDataSource = {
    batch: false,
    transport: {
      read: {
        url: serviceRoot + "/DiagramConnections",
        dataType: "jsonp"
      },
      update: {
        url: serviceRoot + "/DiagramConnections/Update",
        dataType: "jsonp"
      },
      destroy: {
        url: serviceRoot + "/DiagramConnections/Destroy",
        dataType: "jsonp"
      },
      create: {
        url: serviceRoot + "/DiagramConnections/Create",
        dataType: "jsonp"
      },
      parameterMap: function (options, operation) {
        if (operation !== "read") {
          return { models: kendo.stringify(options.models || [options]) };
        }
      }
    },
    schema: {
      model: {
        id: "id",
        fields: {
          id: { from: "Id", type: "number", editable: false },
          from: { from: "FromShapeId", type: "number" },
          to: { from: "ToShapeId", type: "number" },
          fromX: { from: "FromPointX", type: "number" },
          fromY: { from: "FromPointY", type: "number" },
          toX: { from: "ToPointX", type: "number" },
          toY: { from: "ToPointY", type: "number" }
        }
      }
    }
  };

  $("#diagram").kendoDiagram({
    layout: {
      type: "layered"
    },
    dataSource: shapesDataSource,
    connectionsDataSource: connectionsDataSource,
    editable: {
      tools: ["edit"]
    },
    connectionDefaults: {
      editable: {
        tools: ["edit"]
      }
    },
    edit: onEdit
  });
</script>
In this article