)
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. (Last updated on: June 24, 2019).
Unfortunately, activation email could not send to your email. Please try again.
Essential JS2

Syncfusion jQuery based widgets are no longer in active development. Switch to our pure JavaScript based next generation Essential JS 2 library.

Syncfusion Feedback

Establish connection when a node is dropped on a connector

Platform: jQuery |
Control: ejDiagram |
Published Date: November 11, 2015 |
Last Revised Date: May 30, 2019

Establish connection when a node is dropped on a connector:

You can use the diagram client side API Event “drop” to establish the connection when node is dropped over the connector.

The following code illustrates how to establish the connection when node is dropped over the connector.

[JS]

$("#DiagramContent").ejDiagram({
    drop: drop,
    connectors: [
        {
            name: "Link1", segments: [{ type: "orthogonal" }], sourcePoint: { x: 0, y: 0 }, targetPoint: { x: 40, y: 40 }, targetDecorator: { shape: "arrow" }, lineWidth: 2,
            //enable Allow drop on the connector.
            constraints: ej.datavisualization.Diagram.ConnectorConstraints.Default | ej.datavisualization.Diagram.ConnectorConstraints.AllowDrop,
        }
    ]
})
 
function drop(args) {
    var diagram = $("#DiagramContent").ejDiagram("instance");
    if (args.target.type === "connector") {
        //set the node as targetnode if connector already has source node.
        if (args.target.sourceNode) {
            diagram.updateConnector(args.target.name, { targetNode: args.element.name });
        }
        //set the node as sourcenode if connector already has target node.
        else if (args.target.targetNode) {
            diagram.updateConnector(args.target.name, { sourceNode: args.element.name });
        }
        //set the node as source/target node if connector dont have both source/target node.
        else if (!(args.target.sourceNode && args.target.targetNode)) {
            diagram.updateConnector(args.target.name, { sourceNode: args.element.name });
        }
    }
}

 

ADD COMMENT
You must log in to leave a comment

Please sign in to access our KB

This page will automatically be redirected to the sign-in page in 10 seconds.

Up arrow icon

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile
Live Chat Icon