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: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

How to perform Drag and drop operation in OrgChart

Platform: ASP.NET Web Forms |
Control: Diagram |
Published Date: December 15, 2015 |
Last Revised Date: May 30, 2019

How to perform Drag and Drop operation in OrgChart

In the Orgchart sample, we can drag and drop the node onto another node using the drop event which establish the parent/child relationship. Also we need to enable the AllowDrop constraints which shows the highlighter, when we drag the node and mouse hover on the another node. Please refer to the code example below.

ASPX

<ej:Diagram ID="BusinessChart" runat="server" Height="100%" Width="100%" EnableContextMenu="false">
                    <Layout Type="OrganizationalChart" MarginY="30" HorizontalSpacing="40" VerticalSpacing="40" />
                        <SnapSettings SnapConstraints="None" />
             </ej:Diagram>

 

ASPX.CS

//Enable the Allowdrop constraints which shows the highlighter, when we drag the node and mouse hover on the another node.      BusinessChart.Model.DefaultSettings.Node = new Node() {Constraints=NodeConstraints.Default |NodeConstraints.AllowDrop };
//define drop event
BusinessChart.OnClientDrop = "drop";

 

ASPX

function drop(args) {
   var diagram = $("#BusinessChart").ejDiagram("instance");
   if (!args.source.cssClass) {
     if (diagram.getObjectType(args.target) == "node") {
        if (args.element) {
           var connector = diagram.findNode(args.element.inEdges[0]);
         }
         if (connector) {
            diagram.updateConnector(connector.name, { sourceNode: args.target.name, targetNode: args.element.name });
          }
          else {
              diagram.add({ name: "connector" + ej.datavisualization.Diagram.Util.randomId(), segments: [{ type: "orthogonal" }], sourceNode: args.target.name, targetNode: args.element.name });
               }
        }
     }
     //update the layout
     diagram.layout();
  }

 

2X faster development

The ultimate ASP.NET Web Forms UI toolkit to boost your development speed.
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.

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