Articles in this section
Category / Section

How to perform Drag and drop operation in OrgChart in ASP.NET Web Forms Diagram?

1 min read

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();
  }

 

Note:

A new version of Essential Studio for ASP.NET is available. Versions prior to the release of Essential Studio 2014, Volume 2 will now be referred to as a classic version. The new ASP.NET suite is powered by Essential Studio for JavaScript providing client-side rendering of HTML 5-JavaScript controls, offering better performance, and better support for touch interactivity. The new version includes all the features of the old version, so migration is easy.

The Classic controls can be used in existing projects; however, if you are starting a new project, we recommend using the latest version of Essential Studio for ASP.NET. Although Syncfusion will continue to support all Classic Versions, we are happy to assist you in migrating to the newest edition.

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 check out 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 forumsDirect-Trac, 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)
Please sign in to leave a comment
Access denied
Access denied