Articles in this section
Category / Section

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

4 mins 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 in ASP.NET MVC Diagram. 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.

 

Controller

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

 

Cshtml

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

 

 

Conclusion

I hope you enjoyed learning about how to perform Drag and drop operations in OrgChart in ASP.NET MVC Diagram.

You can refer to our ASP.NET MVC Diagram feature tour page to know about its other groundbreaking feature representations and documentation, and how to quickly get started for configuration specifications. You can also explore our ASP.NET MVC 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 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