Set Port-Connector Draw Constraints

Hello,
I have got two questions:

1) I currently have nodes with ports and already activated that a connector can be drawn when hovering over the port.
Is it possible to directly set constraints on connector that is drawn from a specific port?

2) Is it possible to require a connector to be connected to an other port and not just a point for example? So if a user connects a port to any point that this will not be possible and the connector gets cleared.

Thank you!

3 Replies 1 reply marked as answer

GG Gowtham Gunashekar Syncfusion Team March 25, 2021 02:09 PM UTC

Hi Rohansa, 
 
1) I currently have nodes with ports and already activated that a connector can be drawn when hovering over the port. 
Is it possible to directly set constraints on connector that is drawn from a specific port? 
 
We suggest you to set the draw constraints to a specific required port, not for all the port, so the connector can be draw from specific port. We have added a sample to demonstrate how to set draw constraints bottom port of the node. 
 
2) Is it possible to require a connector to be connected to an other port and not just a point for example? So if a user connects a port to any point that this will not be possible and the connector gets cleared. 
 
We suggest you to use collectionChange event to add the your own restriction. whenever a new node or connector added in the diagram the collectionChange event will trigger. In the event we can add restriction and cancel the addition of node and connector if necessary. 
 
Code snippet: 
collectionChange={args => { 
                  if ( 
                    args.element && 
                    (args.element.sourcePortID === "" || 
                      args.element.targetPortID == "") 
                  ) { 
                    args.cancel = true; 
                  } 
                }} 
 
 
 
The above condition allow the port to port connection of connector and cancel the port to node connection. 
 
Regards  
Gowtham 
 


Marked as answer

RO Rohansa March 26, 2021 08:42 AM UTC

Thanks a lot, that solved it! :)


GG Gowtham Gunashekar Syncfusion Team March 29, 2021 12:33 PM UTC

Hi Rohansa, 
 
Thanks for your update. Please let us know whether you need any further assistance on this. 
 
 
Regards, 
Gowtham 


Loader.
Up arrow icon