I’m trying to remove link data from my graph but it isn’t working. I have tried both removeLinkData as well as removeLinkDataCollection within the transaction but to no result.
What are you trying?
You do need to find the exact Object that is the link data (i.e. the value of Link.data if you are using a GraphLinksModel). I suppose you could call Diagram.findLinksByExample. Or you could find a Node by calling Diagram.findNodeForKey or Diagram.findNodeForData and then call Node methods to find connected Links.
I did what you asked of me but even that doesn’t works for me.Below is the code:
node = myDiagram.findNodeForKey(nodeData.key);
links = node.findLinksConnected();
var edge = links.value;
data = edge.data;
First, as with any transactional system, you should not be performing transactions inside loops like that.
Second, why don’t you remove the Links from the Diagram instead of removing the link data from the Model?
var node = . . . myDiagram.startTransaction("Deleted Links"); myDiagram.removeParts(node.findLinksConnected()); myDiagram.commitTransaction("Deleted Links");
Or, if you don’t mind changing the current selection:
var node = ... myDiagram.selectCollection(node.findLinksConnected()); myDiagram.commandHandler.deleteSelection();
(Commands and tools execute their own transactions.)
thanks, it worked great.