How to get list of nodes and their order in the diagram created using symbol-palette

Hi,

I am trying to get the relation between different nodes created by drag-drop from symbol-pallet. On click of the save button, I want to generate the relationship between each nodes based on inEdges/outEdges values.

Is it the best approach? I was not able to get all the nodes from the diagram . Thought I was able to get the details for a selected node but that will not solve my purpose.
Please suggest.

Thanks.

1 Reply

SG Shyam G Syncfusion Team March 16, 2020 09:45 AM UTC

Hi Narendar, 
 
Yes, you can use node inEdges/outEdges property to generate the relationship between each nodes. We get all the nodes from diagram nodes property. Please refer to a code example and the sample below. 
 
Code example: 
  save() { 
    //get all the nodes in the diagram 
    let nodes = this.diagram.nodes; 
    if(nodes.length > 0) { 
      for(var i=0; i < nodes.length; i++) { 
        var node = nodes[i]; 
        if((node as any).inEdges.length > 0) { 
          //iterate a inEdges property 
        } 
         if((node as any).outEdges.length > 0) { 
          //iterate a inEdges property 
        } 
      } 
    } 
  }  
 
 
 
Regards, 
Shyam G 


Loader.
Up arrow icon