We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

how to get the nodes list and connectors after changes made in front end

I am trying to use the flow chart with .net core. I want to get the nodes and connectors list to my controller after the changes made in the front end. How to do that? Any sample project can I get? Thanks

3 Replies

SG Shyam G Syncfusion Team July 20, 2019 01:58 AM UTC

Hi Aung, 
We have created a sample in which when we click a GetDiagramController button we save a diagram using diagram saveDiagram method and send that Json to server side using Ajax. In server side, you can deserialize an JSON string and process nodes and connectors. Please refer to a code example and sample below. 
Code example: 
     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; 
            } 
        }  
 
 
Regards, 
Shyam G 



AM Aung Myo July 24, 2019 02:49 AM UTC

Hi Shyam G ,

Thanks for your support. It works.


RT Ramya Thirugnanam Syncfusion Team July 24, 2019 06:30 AM UTC

Hi Aung,  
 
Thanks for your update. 
 
Regards,  
Ramya T  


Loader.
Live Chat Icon For mobile
Up arrow icon