This is a migrated thread and some comments may be shown as answers.

Get Connection Object

2 Answers 35 Views
Diagram
This is a migrated thread and some comments may be shown as answers.
David
Top achievements
Rank 1
David asked on 20 May 2015, 06:52 PM

Hi, I'm testing the diagram component for my app, I'm porting a desktop app that uses Dataweb's diagramming library.

 How do I retrieve an existing connection object since it does not have an element ID?

 

This is what I need:

var connection = diagram.getConnection(params);

Thanks!

David

2 Answers, 1 is accepted

Sort by
0
Accepted
Vessy
Telerik team
answered on 25 May 2015, 04:05 PM
Hi David,

You can access the array containing all connections of a Diagram through the diagram Kendo UI widget like folows:
$find("RadDiagram1").get_kendoWidget().connections;

Unfortunately, as the connections do not expose an id property (their ID is automatically generated), the only possible approach I can suggest you in order to differentiate between the different connections is to implement your logic depending on each connection's from- and to- shape. For example:
function getConnetion() {
    var diagram = $find("RadDiagram1").get_kendoWidget();
    var connections = diagram.connections;
    var conID, fromShape, toShape;
 
    for (var i = 0; i < connections.lenght; i++) {
        fromShape = diagram.connections[i].from;
        toShape = diagram.connections[i].from;
        conID = getConnectionID(fromShape, toShape);
    }
     
}
function getConnectionID(fromShape, toShape) {
    var returnValue = "";
 
    if (fromShape == "s1" && toShape == "s2") {
        returnValue = "connection1";
    }
    else if (fromShape == "s2" && toShape == "s3") {
        returnValue = "connection3";
    }
    //etc.
    return returnValue;
}


Regards,
Vessy
Telerik
0
David
Top achievements
Rank 1
answered on 25 May 2015, 05:07 PM
Thanks Vessy, I did that already.
Tags
Diagram
Asked by
David
Top achievements
Rank 1
Answers by
Vessy
Telerik team
David
Top achievements
Rank 1
Share this question
or