Store extra values on Diagram nodes

I'm trying to keep the corresponding database ID for each node in the object. The only way I've found to do this is to keep the ID in the cssClass:

    diagram.updateLabel(element.name, element.labels[0], { text: activityDescription, cssClass: activityID });

And to access it later:

    var id = element.labels[0].cssClass;

This works, but I would rather avoid any potential unwanted behaviour or confusion.

I have tried using { id: activityID } but it is undefined when I try element.labels[0].id;

Is there any property I can use apart from cssClass for this purpose?

Thanks

1 Reply

SG Shyam G Syncfusion Team June 25, 2018 06:53 AM UTC

Hi David, 

Please use node’s addInfo property to define a custom property. please refer to the code example and  help documentation below. 

Code example: 
BasicShape node = new BasicShape(); 
   //create addInfo property for node 
 Dictionary<string, object> addInfo = new Dictionary<string, object>(); 
 addInfo.Add("Id", "123"); 
 node.AddInfo = addInfo; 


Regards, 
Shyam G 


Loader.
Up arrow icon