To create a new node i have used below code
vm.myDiagram.startTransaction(“add node and link”);
vm.myDiagram.model.addNodeData({ key: vm.myDiagram.model.nodeDataArray[0].key+vm.i , name:vm.draggedNodeName , color: “#F0F0F0” , location: “100 -50”}); // this makes sure the key is unique
vm.myDiagram.model.addLinkData({ from: vm.myDiagram.model.nodeDataArray[0].key, to: vm.myDiagram.model.nodeDataArray[0].key+vm.i });
vm.myDiagram.commitTransaction(“add node and link”);
which works fine now i need to delete node i have written like below but it did;nt work
vm.myDiagram.startTransaction(“remove node data”);
vm.myDiagram.model.removeNodeData({ key: vm.myDiagram.model.nodeDataArray[index+1].key , name:reportname , color: “#F0F0F0” , location: “100 -50”}); // this makes sure the key is unique
vm.myDiagram.commitTransaction(“remove node data”);
Models use equality by reference, so you are asking to remove a new node data object, which cannot already exist in the model. Call Diagram.findNodesByExample if you really want to do that.
But in this case you don’t.
var node = myDiagram.findNodeForKey(...key...);
if (node !== null) {
myDiagram.startTransaction();
myDiagram.remove(node);
myDiagram.commitTransaction("deleted node");
}
thanks walter.
I have a few qns :
1)On selecting node or on canvas hover i see a blue border displayed i need to remove that is there any event to do that.
2)I need to customize context menu and apply some css according to my need can we do that.
3) the links created can be dragged with mouse drag i need to stop that once the link created it should not be draggable.