- Home
- Forum
- ASP.NET Web Forms
- How to create connector on node drop
How to create connector on node drop
Attachment: node_435c873b.zip
Thanks for using Syncfusion products.
We are glad to let you know that we have created a simple sample to achieve your requirement and it is available in the below link for download. Please refer the code snippet below.
Code snippet:
<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
Thanks for using Syncfusion products.
Could you please confirm the Essential studio version that you are using in your application? If the version is 13.1.0.21, then it is a known issue and it is fixed in the version 13.1.0.26. So we suggest you to upgrade to the version 13.1.0.26 to resolve your reported issue.
Please let me know if any concerns.
Regards,
Shyam G
So continue for the Issue 2. Is there any method to achieve my goal?
As attached are the videos.
nodeori is about the initial behavior when I drag then node before applying the OnNodeDrag function.
Attachment: Video_6bf39917.zip
Thanks for your update.
|
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. |
Please let me know if any concerns.
Regards,
Shyam G
Thanks for using Syncfusion products.
The reported issue is a breaking issue and the fix for this issue is estimated to be available on volume 2 service pack 2 release, which is scheduled to be released by the end of August,2015.
Please let us know if you need further assistance.
Regards,
Shyam G
- 9 Replies
- 2 Participants
-
AP Alvin Phang
- May 19, 2015 07:03 AM UTC
- Aug 20, 2015 12:40 PM UTC