)
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. (Last updated on: June 24, 2019).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

How to add custom properties to nodes and connectors?

Platform: ASP.NET MVC |
Control: Diagram |
Published Date: December 18, 2014 |
Last Revised Date: May 30, 2019

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);

 

2X faster development

The ultimate ASP.NET MVC UI toolkit to boost your development speed.
ADD COMMENT
You must log in to leave a comment

Please sign in to access our KB

This page will automatically be redirected to the sign-in page in 10 seconds.

Up arrow icon

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile
Live Chat Icon