Server Side Diagram Access or JSON Generation

1. Is there a way to access the Diagram from the server side. (ie controller)?  I know that some server side controls give you a way to do that.
2. If not, is there a way for me to generate some kind of json from the diagram?

3 Replies 1 reply marked as answer

GG Gowtham Gunashekar Syncfusion Team August 27, 2020 12:12 PM UTC

Hi DSoftware,  
There is no way to access the diagram instance from server side. But we get the diagram as JSON using saveDiagram public API and also we can able to load the diagram from previously saved JSON. After the diagram has been saved as JSON, we can send the JSON data to the server through ajax and processing it depending on our need. 
 Documentation Link: 
 
// create the Diagram JSON 
Var JSON =diagram.saveDiagram(); 
// load the diagram 
diagram.loadDiagram(JSON); 
Regards 
Gowtham 
 



DS dsoftware August 27, 2020 02:03 PM UTC

Gowtham,

I don't know if I posted to the wrong forum or not but I don't think I am not using ej2.  I think I am using ej.  Is there an equivalent to this?  This is what I get when I attempt to run the following.

Code:
     var diagramElement = document.getElementById('Diagram');
     var diagram = diagramElement.ej2_instances[0];
     var JSON = diagram.saveDiagram();

Result:
     Uncaught TypeError: diagramElement.ej2_instances is undefined

I have also tried this (using the method to get the diagram that I have been using everywhere else in my JS)

Code:
     var diagram = $("#Diagram").ejDiagram("
     var JSON = diagram.saveDiagram();

Result:
     Uncaught TypeError: diagram.saveDiagram is not a function


NG Naganathan Ganesh Babu Syncfusion Team August 28, 2020 05:31 AM UTC

Hi DSoftware, 
Sorry for the inconvenience caused. 
Please refer the below our UG documentation link for how to serialize the diagram in EJ1. 
Regards, 
Naganathan K G 


Marked as answer
Loader.
Up arrow icon