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

Remove Connector in javascript.

Thread ID:

Created:

Updated:

Platform:

Replies:

125619 Aug 29,2016 11:18 AM UTC Aug 31,2016 05:07 AM UTC JavaScript 3
loading
Tags: ejDiagram
Andreas Bürstner
Asked On August 29, 2016 11:18 AM UTC

Hi all,
I'am searching for a method to delete a selected connector programmatically.
I tried the following methods, but the connector will not be removed from the Diagramm:

1. Version
 var diagram = $('#DiagramContent').ejDiagram("instance");
 var  selectedItem = dialog.selectedItems[0]; // The connector was selected by the user
diagram.remove(selectedItem);
diagram.layout();

Because this doesn't work I tried the following:
var diagram = $('#DiagramContent').ejDiagram("instance");
 var  selectedItem = dialog.selectedItems[0]; // The connector was selected by the user
 var cons = $('#DiagramContent').ejDiagram("connectors");
 cons.splice($.inArray(conToDelete,cons),1);
diagram.layout();

After I am doing this Version, when I take a look in the model of the diagram, the connectors Array has lost the selected connector, but the diagram always shoes the connector between the nodes. I am using OrganizationalChart as layout type.

Hope that aybody can help me. Thanks in advanced

Andreas

Shyam G [Syncfusion]
Replied On August 30, 2016 04:27 AM UTC

Hi Andreas, 

We have created a sample to achieve your requirement and it is available in the below link for download. Please refer to the code example below. 

Code example: 
    var diagram = $("#diagram").ejDiagram("instance"); 
    //to get the selected items 
    var selectedItem = diagram.model.selectedItems.children[0]; 
    if (selectedItem) { 
     //remove the selected item 
        diagram.remove(selectedItem); 
    } 
    //update the layout 
    diagram.layout(); 


Regards, 
Shyam G 


Andreas Bürstner
Replied On August 30, 2016 02:44 PM UTC

Hi Shyam,
thanks for your Reply. That was what I had done. So I have searched for another mistake I had made, and found it. I assumed, that when I remove the "Delete" constrain I only deny the deletion by using the ContextMenu or the ESC-Key. Because this should not be possible for the user, I am now Setting this flag before I call diagram.remove, an now all works as excpected.

Very Thanks

Andreas

Shyam G [Syncfusion]
Replied On August 31, 2016 05:07 AM UTC

Hi Andreas, 

We are happy to hear that your problem is resolved. 

Regards, 
Shyam G 


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

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

;