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
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.
Yes that works, thank you.
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