Articles in this section

How to Prevent Multiple Connectors From a Port in React Diagram?

This article explains how to prevent multiple connectors from a port in React Diagram. To prevent a connector from being drawn from a port that already has a connector connected to it in React Diagram, you can use the elementDraw event. This event is triggered when a connector is being drawn from a port.

By examining the arguments of the event, we can check for existing connections and cancel the drawing if the port is already connected.

Below is an example of how to implement this functionality:

elementDraw = {function (args) {
               if (args.state == 'Start') {
                 let ports = args.source.ports;
                 if (ports && diagramInstance.nodes !== undefined) {
                   for (let j = 0; j < ports.length; j++) {
                     let port = ports[j];
                     if (port && (port.outEdges.length > 0 || port.inEdges.length > 0)) {
                       args.cancel = true;
                     }
                   }
                 }
               }
}} 

Refer to the working sample for additional details and implementation: Click Here

Conclusion

We hope you enjoyed learning how to prevent multiple connectors from a port in React Diagram.

You can refer to our React Diagram feature tour page to learn about its other groundbreaking feature representations and documentation, and how to quickly get started with configuration specifications. You can also explore our React Diagram example to understand how to create and manipulate data.

For current customers, you can check out our components from the License and Downloads page. If you are new to Syncfusion®, you can try our 30-day free trial to explore our other controls.

If you have any queries or require clarifications, please let us know in the comments section below. You can also contact us through our support forums, BoldDesk Support, or feedback portal. We are always happy to assist you!

Did you find this information helpful?
Yes
No
Help us improve this page
Please provide feedback or comments
Comments (0)
Access denied
Access denied