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. Image for the cookie policy date
close icon

Problems with dragging nodes in diagram scripts

Hello.
I need to implement simple dragndrop functionality in your diagram control. Just need to highlight target node. I also need to replace dragged and target nodes, but it doen't works as well. 
I have implemented simple scipts, but it doesn't work by some cause. Looks like diagram drag event specifically handled nodes and can't change it as required.
Could you please show me how could I accomplish my task?
You could found my script in attachment and get aspx with diagram from this topic (https://www.syncfusion.com/forums/133019/asp-diagram-drag-n-drop-nodes)

Attachment: DragNodes_aee61a22.7z

3 Replies

SG Shyam G Syncfusion Team October 6, 2017 06:20 AM UTC

Hi Andrey, 
 
Please enable the AllowDrop constraints for nodes/connectors which shows the highlighter, when we drag the node/connector and mouse hover on the another node/connector. Also use drop event to achieve your requirement and this event triggers when we drag the node/connector and drop it onto another node/connector. Please refer to the code example and  modified sample below. 
 
Code example: 
 
//define drop event 
eliminationChart.OnClientDrop = "drop"; 
 
  function drop(args) { 
            var diagram = $("#EliminationChart").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(); 
        } 
 
 
Please refer to the KB link below which shows how to perform drag and drop operation in layout. 
 
 
Regards, 
Shyam G 



AK Andrey Kucher October 9, 2017 09:31 AM UTC

Thanks, this works!



SG Shyam G Syncfusion Team October 10, 2017 03:59 AM UTC

Hi Andrey, 
Please let us know if you need further assistance on this. 
Regards, 
Shyam G 


Loader.
Live Chat Icon For mobile
Up arrow icon