Query |
Response |
This is very helpful as Im now able to save my diagram on press of the button. Is it possible to save diagram everytime I change something in diagram? I would like to remove all buttons and save everything on the fly immediately. Thank you. |
Yes, you can use the diagram client Side events to perform add/edit/delete operation in the database.
We have used nodeCollectionChange event to perform add/delete operations in the database.
Code example:
//define nodecollectionchange event
model.NodeCollectionChange = "nodecollectionchange";
function nodecollectionchange(args) {
var diagram = $("#Diagram").ejDiagram("instance");
if (args.state === "changed") {
if (args.changeType === "insert") {
diagram.insertData();
}
if (args.changeType === "remove") {
diagram.removeData();
}
}
}
For an edit operation, we have used sizeChange and drag event.
Code example:
//define sizechange event
model.SizeChange = "sizechange";
//define drag event
model.Drag = "drag";
function sizechange(args) {
var diagram = $("#Diagram").ejDiagram("instance");
if (args.resizeState === "completed") {
diagram.updateData();
}
}
function drag(args) {
var diagram = $("#Diagram").ejDiagram("instance");
if (args.dragState === "completed") {
diagram.updateData();
}
}
Please refer to the sample below.
|
What the is purpose of DiagramBuilderData.designer.cs in your sample? Should I transfer this to my project? Why it is not part of Syncfusion framework? |
You need to transfer entire dbml file(DiagramBuilderData.dbml, DiagramBuilderData.dbml.layout, DiagramBuilderData.designer.cs) to your project. We use linq to sql approach. The DBML file is mapping that defines your classes based on your database schema.
Linq to Sql uses a database-first approach where you have the database and model your classes after the DB schema. By dragging & dropping the table onto there, you'll be automating the creation of the classes(for example: DiagramBuilderData.designer.cs is automatically generated which contains the classes and properties). |