<ej:Diagram ID="DiagramContent" runat="server" Height="500px" Width="500px">
</ej:Diagram>
DiagramContent.OnClientDrop = "drop";
function drop(argument) {
if (argument && argument.element) {
var node = argument.element;
var diagramObj = $("#DiagramContent").data("ejDiagram");
for (var i = 0; i < node.ports.length; i++) {
if (node.ports[i].name.toLowerCase() == "inport") {
continue;
}
else {
diagramObj.add({ name: "conn", sourcePort: "outport", sourceNode: node.name, targetPoint: { x: node.offsetX + 200, y: node.offsetY } })
}
}
}
}
Here is the sample
Sample:http://www.syncfusion.com/downloads/support/forum/119178/connectionsample1-1904053146.zip
Please let me know if any concerns.
Regards,
Shyam G
Query |
Response |
Issue 1 Previously I was using 13.1.0.21 and I have upgraded to 13.1.0.26. But still I have the same problem. (refer to video connector2)
In my project, I set the constraint using the code below.
conn.constraints = ej.datavisualization.Diagram.ConnectorConstraints.Default & (ej.datavisualization.Diagram.ConnectorConstraints.DragSourceEnd);
|
Please note that the reported issue is a known issue and it has been fixed in our Essential Studio service pack 2 for Volume 1, 2015 and it is available for download under the following link. http://www.syncfusion.com/forums/119275/essential-studio-2015-volume-1-service-pack-2-release-v13-1-0-30-available-for-download Here is the code snippet to disable DragSourceEnd and Drag of the connector Code snippet: Connector connect = new Connector(); //disable the connector DragSourceEnd and Drag connect.Constraints = ConnectorConstraints.Default & ~(ConnectorConstraints.DragSourceEnd | ConnectorConstraints.Drag); |
Issue 2 On node drag event, I wish to have connectors which are not targeted to any node to move together. So I was trying to update the connector target point as the node is being dragged. Please refer to the code snippet below.
function OnNodeDrag(argument) {
var diagramObj = $("#DiagramContent").data("ejDiagram");
if (!diagramObj || !argument ) { return; }
if (argument.elementType != "node") { return; }
var sourceNode = argument.element.name;
for (var i = 0; i < diagramObj.model.connectors.length; i++) {
if (diagramObj.model.connectors[i].sourceNode != sourceNode) { continue; }
if (diagramObj.model.connectors[i].targetNode) { continue; }
diagramObj.model.connectors[i].targetPoint = { x: argument.element.offsetX, y: argument.element.offsetY + 75 }; diagramObj.updateConnector(diagramObj.model.connectors[i].name, {}); } } |
Please note that the connectors targetPoint can be updated at runtime using updateConnector API method, but we have issue in updating connectors targetPoint and it is a known issue. The fix for this issue is estimated to be available on volume 2,2015 release, which is scheduled to release in the end of June,2015. |