BoldSignEffortlessly integrate e-signatures into your app with the BoldSign API. Create a sandbox account!
function save() {
var file = [];
var diagram = null;
var diagram = $("#diagram1").ejDiagram("instance");
for (i = 0; i < diagram.model.nodes.length; i++) {
var shape = diagram.model.nodes[i];
//push the shape into array
file.push(shape);
}
var Jsonsave= diagram.save();
//convert JSON object to JSON string
var Jsonstringify = JSON.stringify(file);
$.ajax({
url: "/Entity/save",
type: "Post",
dataType: "json",
data: { "jsonstring": Jsonstringify },
success: function (Jsonstringify) {
alert("Success");
return true;
},
});
}
[HttpPost]
public ActionResult save(string jsonstring)
{
JArray objects = JArray.Parse(jsonstring);
JArray items = (JArray)objects;
int length = items.Count;
for (int i = 0; i < items.Count; i++)
{
var item = (JObject)items[i];
var name = item["name"].ToString();
string json_data = JsonConvert.SerializeObject(item);
Northwindcontext13DiagramEntities entities = new Northwindcontext13DiagramEntities();
SaveDatabase save = new SaveDatabase();
//diagram name
save.DiagramName = "Diagram";
//json data
save.Jsondata = json_data;
//node name
save.Nodename = name;
entities.SaveDatabases.Add(save);
entities.SaveChanges();
}
return null;
}
Sample: http://www.syncfusion.com/downloads/support/directtrac/132775/saveeachshape475109138.zip
Regards,
Shyam G
1.we can get the connectors directly from the diagram.connectors collection
2.we can get the connector from the node.outEdges collection to get the flow of the diagram.
Both the ways are given in the below code snippet. Please find the below snippet.
function save() {
var file = [];
var diagram = null;
var diagram = $("#diagram1").ejDiagram("instance");
for (i = 0; i < diagram.model.nodes.length; i++) {
var shape = diagram.model.nodes[i];
//push the shape into array
file.push(shape);
}
// you can save the connectors either from connector collection or from the out edges of the nodes. both the methods are described on below code snippet.
// save all the connectors from connector collection
for (i = 0; i < diagram.model.connectors.length; i++) {
var connector = diagram.model.connectors[i];
//push the shape into array
file.push(connector);
}
// save all the connectors from nodes out edges
for (i = 0; i < diagram.model.nodes.length; i++) {
var node = diagram.model.nodes[i];
if (node.outEdges && node.outEdges.length > 0) {
for (j = 0; j < node.outEdges.length; j++) {
var inEdge = diagram.getNode(node.outEdges[i])
file.push(inEdge);
}
}
}
var Jsonsave = diagram.save();
//convert JSON object to JSON string
var Jsonstringify = JSON.stringify(file);
$.ajax({
url: "/Entity/save",
type: "Post",
dataType: "json",
data: { "jsonstring": Jsonstringify },
success: function (Jsonstringify) {
alert("Success");
return true;
},
});
}
Please let me know if you need further assistance.
Regards,
Kameshwaran R.
[HttpPost]
public ActionResult save(string stringify)
{
DiagramProperties data = new DiagramProperties();
//parse the JSON string into model object
data.ParseModel(stringify);
//you can do your code here
return null;
}
Sample:http://www.syncfusion.com/downloads/support/forum/121121/ze/savesample-1243763079
Regards,
Shyam G