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
close icon

GetEdges and GetConnector no longer supported - how is this done now?

Hi,


I am upgrading from the old diagram component (what you now call diagram-classic) and have discovered that

GetEdges and GetConnector are no longer supported.


So this code no longer works:

public async Task<List<DiagramConnector>> FindReachable(string nodeId)
        {
            string[] edges = await diagram.GetEdges(nodeId, true);
            foreach (string edge in edges)
            {
                DiagramConnector connector = diagram.GetConnector(edge);
                if (reachableConnectors.Contains(connector))
                {
                    continue;
                }
                if (connector.Annotations == null || connector.Annotations.Count == 0 || connector.Annotations[0].Content != "No")
                {
                    reachableConnectors.Add(connector);
                    await FindReachable(connector.TargetID);
                }
            }
            return reachableConnectors;
        }

In the new DiagramComponent, how would I search a node for its connectors and iterate through them?


Thanks.

Paul


3 Replies 1 reply marked as answer

SU Sumathi Uthayakumar Syncfusion Team November 24, 2022 12:31 PM UTC

Hi Paul,


In SfDiagramComponent, we have the GetObject method, which takes ID as an argument and returns an IDiagramObject. You can get a connector or node by passing its id to this method. You can get the node’s inedges and outedges collection from InEdges and OutEdges properties of the node by iterating the collection. We modified the code and distributed the code snippet.


public async Task<List<Connector>> FindReachable(string nodeId)

    {

         Node node = diagram.GetObject(nodeId) asNode;

       List<string> edgesCollection=node.InEdges.Concat(node.OutEdges).ToList();        

foreach (string edge in edgesCollection)

            {

Connector connector = diagram.GetObject(edge) asConnector;

if (reachableConnectors.Contains(connector))

                {

continue;

                }

if (connector.Annotations == null || connector.Annotations.Count == 0 || connector.Annotations[0].Content != "No")

                {

                    reachableConnectors.Add(connector);

await FindReachable(connector.TargetID);

                }

            }

return reachableConnectors;

        }

 


Regards,

Sumathi U.


Marked as answer

PA Paul November 24, 2022 08:36 PM UTC

Yes that works, thank you.




PR Preethi Rajakandham Syncfusion Team November 25, 2022 05:15 AM UTC

Hi Paul,

We are glad that the provided response meets your requirement. Please let us know if you need further assistance. As always, we are happy to help you out.

Regards,

Preethi R



Loader.
Live Chat Icon For mobile
Up arrow icon