edit
Edit diagram connection/shape.
Parameters
item Object
A diagram item to edit.
Example - edit the first Diagram shape
<button id="createBtn">Edit first shape</button>
<div id="diagram"></div>
<script>
$("#createBtn").on("click", function(){
var diagram = $("#diagram").getKendoDiagram();
diagram.edit(diagram.shapes[0]);
});
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", editable: false }
}
}
}
};
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"]
}
},
shapeDefaults: {
content: {
template: "#= dataItem.JobTitle #"
}
}
});
</script>