linkDataArray delete a link - Sever interation

Hi,

We have an application where we create a node and connect that node to another node. once user create his diagram he can save the design.

Here is our problem :- whenever we create / modify the diagram we send a indication to server as OperationType (I - Insert, U - Update, D - Delete etc). Everything is fine if we add edit and delete individual components (node or link).

eg:- i have node1 is connecting to node2 and node2 is connecting to node3. Now i deleted node2. node to have incoming link from node1 and outgoing link to node3. When i send operation type to server i am not getting link details which deleted automatically. Node2 operation type is available because of event.

Can you help me to understand how i can get deleted linkDataArray.

Regards
Arun

Hmm, maybe I’m misunderstanding your example, but if your structure is something like

node1 --> node2 --> node3

Then you delete node2, there will be no links left, since the only two links involved node2, which no longer exists.

If you’re asking how to get these deleted links (and inform your server of their deletion), I suppose you could watch the “SelectionDeleted” event. The subject of this event will be a collection of deleted Parts. You could either send Delete indications to your server for each deleted Part, or you could iterate through the deleted Parts collection, searching for Nodes that were deleted with incoming / outgoing links, and inform your server of those.

Read more on events here: https://gojs.net/latest/intro/events.html#SelectionDeleted

Hi Ryanj,
You got it right but i i am using 1.8 version, which doesn’t have selectionDeletion

Regards
Arun

Yes, it does. Make sure you are using the exact string “SelectionDeleted”. I have just tried the following with 1.8.38

myDiagram.addDiagramListener("SelectionDeleted", function (e) {
          console.log(e);
      });

But the problem is the DiagramEvent.subject being a collection of all deleted Parts, rather than just the selected Parts, was new functionality in version 2.0.

In 1.8 or earlier, you’ll need to look at the collection, which is just the Diagram.selection, and you need to do it in a “SelectionDeleting” DiagramEvent, rather than a “SelectionDeleted” DiagramEvent.