We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Edit custom addInfo field programmatically in node

I have a custom data which is updated at api side.
After I get the latest data, I want to update annotation, and addInfo filed for my custom data
nodes[index].addInfo.customObject already stores an old data which I want to rewrite

  function editNode(data) {
       
        let index = this.diagramInstance.nodes.map(e => e.id).indexOf(this.currentNodeId);
        // @ts-ignore
        this.diagramInstance.nodes[index].annotations[0].content = data.title;
        this.diagramInstance.nodes[index].addInfo.customObject = data;
        // @ts-ignore
        this.diagramInstance.dataBind();
    }

Finally, annotation is updated, addInfo - not.
How to update addInfo of node at runtime?

3 Replies

SG Shyam G Syncfusion Team November 28, 2019 09:08 AM UTC

Hi Alex, 

We have created a sample in which we have updated the node addInfo property with custom Data at runtime and shown how to retrieve that custom Data. Could you please check in the below sample? Still if you face issues, please share us more details such as modify the below sample. 

Code example: 
  updateCustomInfo: function () { 
      // get diagram instance 
      var diagram = diagramInstance; 
      //get selected node 
      var node = diagram.selectedItems.nodes[0]; 
      if(node) { 
         node.addInfo.customObject = "newData"; 
     
    }, 
    getCustomInfo: function() { 
        // get diagram instance 
      var diagram = diagramInstance; 
      //get selected node 
      var node = diagram.selectedItems.nodes[0]; 
      if(node) { 
         alert(node.addInfo.customObject) 
     
   




Regards, 
Shyam G 



AB Alex B November 29, 2019 02:21 PM UTC

Thank's worked for me


SG Shyam G Syncfusion Team December 2, 2019 04:04 AM UTC

Hi Alex, 
Thanks for your update. 
Regards, 
Shyam G 


Loader.
Live Chat Icon For mobile
Up arrow icon