All the output ports in all nodes in my palette have the name “Out”, and the input ports have the name “In”. I’m only able to get this name from e.parameter.
But I want the Node from which it is connected.
For eg: If my existing link was connecting node 1 to node 5. Then i want to be able to fetch node 1
So basically, i want to override linkRelinked functionality to specifically remove the existing link and draw a link to the new node, since i have certain event being triggered on removal and drawing of links.
Instead of defining a “LinkRelinked” DiagramEvent listener, I suggest that you override RelinkingTool.reconnectLink, RelinkingTool | GoJS API.
Don’t call the base method, but just replace the link:
$(go.Diagram, . . .,
{
. . .,
"relinkingTool.reconnectLink": function(existinglink, newnode, newport, toend) {
// this example assumes only one port per node
var fromnode = existinglink.fromNode;
var tonode = existinglink.toNode;
// this assumes it's a GraphLinksModel, not a TreeModel:
this.diagram.model.removeLinkData(existinglink.data);
if (toend) {
this.diagram.model.addLinkData({ from: fromnode.key, to: newnode.key });
} else {
this.diagram.model.addLinkData({ from: newnode.key, to: tonode.key });
}
}
})