Articles in this section
Category / Section

How to add custom properties to nodes and connectors in .NET MVC Diagram ?

1 min read

You can add Custom properties to Node and Connector.

JavaScript

In JavaScript, you can add custom properties directly into the node object.

JS

var nodes = [];
var node = 
  {
   name: "node",
   //custom properties for node
   email:"gs@gmail.com",
   phone:"23456678",
  }
nodes.push(node);
var connectors=[];
var connector = 
   {
    name: "connector1",
    segments: [{ type:"straight" }], 
    //custom properties for connectors
    email:"gs@gmail.com",
    phone:"23456678",
   };
   connectors.push(connector);

ASP.NET MVC and ASP.NET

In MVC and ASP.NET, custom properties for Node and Connector can be added by inheriting respective classes. The custom property can be retrieved at client side by setting attributes.

Note:

Custom properties must be serializable, else you cannot access it in client side.

 

EJMVC/EJWEB

public class CustomNode:Node
    {
        private string email;
        private string phone;
        [JsonProperty("email")]
        [DefaultValue("")]
        public string Email
        {
            get { return email; }
            set { email = value; }    
        }
        [JsonProperty("phone")]
        [DefaultValue("")]
        public string Phone
        {
            get { return phone; }
            set { phone = value; }
        }
}
CustomNode nodes = new CustomNode();
   nodes.Name = "Rectangle";
   //custom properties for node
   nodes.Email = "gs@gmail.com";
   nodes.Phone = "23456678";
model.Nodes.Add(nodes);
public class CustomConnector :Connector
    {
        private string email;
        private string phone;
        [JsonProperty("email")]
        [DefaultValue("")]
        public string Email
        {
            get { return email; }
            set { email = value; }    
        }
        [JsonProperty("phone")]
        [DefaultValue("")]
        public string Phone
        {
            get { return phone; }
            set { phone = value; }
        }
}
CustomConnector connectors = new CustomConnector();
    connectors.Name = "line";
    //custom properties for connectors
    connectors.Email = "gs@gmail.com";
    connectors.Phone = "23456678";
model.Connectors.Add(connectors);

 

Conclusion

I hope you enjoyed learning about how to add custom properties to nodes and connectors in .NET MVC Diagram.

You can refer to our .NET MVC Diagram feature tour page to know about its other groundbreaking feature representations and documentation, and how to quickly get started for configuration specifications. You can also explore our example to understand how to create and manipulate data.

For current customers, you can check out our components from the License and Downloads page. If you are new to Syncfusion, you can try our 30-day free trial to check out our other controls.

If you have any queries or require clarifications, please let us know in the comments section below. You can also contact us through our support forumsDirect-Trac, or feedback portal. We are always happy to assist you!

Did you find this information helpful?
Yes
No
Help us improve this page
Please provide feedback or comments
Comments (0)
Please sign in to leave a comment
Access denied
Access denied