update existing node

I'm using the react-diagram and place nodes dynamically via code to the diagram.

Now I want to update one of the nodes.

To make it easy I just create a new node with the same Id and want to replace the existing (all connections should remain).

I hav'nt found a way to do this.


how can i simply update a existing node or ?


1 Reply 1 reply marked as answer

SS Sivakumar Sekar Syncfusion Team November 12, 2021 10:58 AM UTC

Hi Tobias, 

By default, in the diagram, we have support to update the existing node. Instead of deleting the node and adding the new node with the same id, you can update the existing node. By using the node’s properties you can able to update the node. The node’s offsetX and offsetY properties are used to change the position of the node and height, width properties are used to change the size of the node. The style property is used to change the appearance of the node. Get the specific node using that node id and you can update that node. Please refer to the below code snippet 

function updateNode() { 
// Get the specific node using the diagram getObject method 
    var node = diagram.getObject("node1"); 
    node.offsetX = 120; 
    node.offsetY = 200; 
    node.width = 100; 
    node.height = 100; 
    node.style.fill = "red"; 
    diagram.dataBind(); 
 

We have already prepared a sample in our live demos to update the node style. Please find the sample in the below link 


Regards,           
Sivakumar 



Marked as answer
Loader.
Up arrow icon