Delete node when it is dropped to diagram

Hi there,
1. I just wanted to delete a node when it is dragged from symbol palette and dropped on diagram
2. I want remove lines displaying with the node while dragging, refer to this image: https://www.screencast.com/t/Vl6AHBtf2Em7

1 Reply

NG Naganathan Ganesh Babu Syncfusion Team September 14, 2018 10:20 AM UTC

Hi Ahman,  
I just wanted to delete a node when it is dragged from symbol palette and dropped on diagram 
We can use drop event args “cancel” property to set false to prevent the node insert into the diagram. please refer to the below code example. 
 
Code example: 
 
drop:function (args) { 
args.cancel = false; 
} 
 
 
Also if you need to delete the node after added into the diagram, we suggest you to use nodeCollectionChange event when the args “state” as “changed” and the “changeType” as “insert”. Please refer to the below code example. 
 
Code example: 
 
function nodeCollectionChange(args) { 
            if (args.state === "changed" && args.changeType === "insert") { 
                var diagram = $("#diagram").ejDiagram("instance"); 
                var node  = args.element; 
                diagram.remove(node); 
            } 
        } 
  
I want remove lines displaying with the node while dragging, refer to this image:https://www.screencast. com/t/Vl6AHBtf2Em7 
We suggest you to disable the snapSettings “enableSnapToObject” property to achieve your requirement. please refer to the below our online UG documentation link.https://help.syncfusion.com/js/diagram/gridlines#snap-to-objects

Regards, 
Naganathan K G 


Loader.
Up arrow icon