@shantanoo-desai wrote:
- I already render my diagram once.
- Upon node click I obtain a newly generated arrays for node and link data.
How should I go about deleting the
nodeDataArray
andlinkDataArray
?within_trigger_function(...) { let newInstance = new BtreeClass(); // generate new arrays.. let newNodeDataArray = newInstance.getNodeDataArray(); let newLinkDataArray = newInstance.getLinkDataArray(); let model = this.myDiagram.model; model.startTransaction('remove nodes and links'); if(model instanceof go.GraphLinksModel) { model.removeLinkDataCollection(model.linkDataArray); } model.removeNodeDataCollection(model.nodeDataArray); model.commitTransaction('remove nodes and links'); }
This somehow only removes certain nodes and links
and throws an error
value is not an instance of object: undefined
Upon investigating, the nodes removed from the transaction are only odd number ones. The error prevails only when remove links and nodes.
Upon adding a new transaction like below the removal and commenting out the removal part:
model.startTransaction('add nodes and links'); model.addNodeDataCollection(newNodeDataArray); model.addLinkDataCollection(newLinkDataArray); model.commitTransaction('add nodes and links');
I get a jumbled up render of the links and nodes which makes sense as none of the links and nodes were previously removed.
Is it possible what I am doing? where can I use the
ChangedEvents
fornodeDataArray
andlinkDataArray
and how?All of this just so that I do not have to render the diagram completely again and lose all my selections from previous rendering
Posts: 3
Participants: 2