function getDiagramController() {
var diagram = document.getElementById("container").ej2_instances[0];
var JsonData = diagram.saveDiagram();
//pass an saved JSON to an server side
$.ajax({
url: "/Diagram/DiagramJson",
type: "Post",
dataType: "json",
data: { "JsonData": JsonData },
success: function (JsonData) {
alert("Success");
return true;
},
})
}
[HttpPost]
public void DiagramJson(string JsonData)
{
Dictionary<string,object> DiagramData = JsonConvert.DeserializeObject<Dictionary<string, object>>(JsonData);
//To get nodes collection
List<DiagramNode> Nodes = JsonConvert.DeserializeObject <List<DiagramNode>> (DiagramData["nodes"].ToString());
//Iterate an nodes
foreach(var node in Nodes)
{
// process each node
node.Width = 100;
}
//To get connectors collection
List<DiagramConnector> Connectors = JsonConvert.DeserializeObject<List<DiagramConnector>>(DiagramData["connectors"].ToString());
//Iterate an connectors
foreach (var connector in Connectors)
{
// process each connector
connector.CornerRadius = 0.5;
}
} |