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.
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Custom node client side

Thread ID:

Created:

Updated:

Platform:

Replies:

123378 Mar 11,2016 02:01 PM UTC Mar 17,2016 09:28 AM UTC ASP.NET MVC 7
loading
Tags: Diagram
David
Asked On March 11, 2016 02:01 PM UTC

Hi!

I have a Diagram and i try create Custom Nodes with extra information. In side server i create my custom node:

public class GaugeNode : 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; }
        }

    


       
    }


And add to my diagram:
 GaugeNode newIdea = CreateNode("NewIdea", 400, 400, 400, 300, "New Idea Identified");
            newIdea.Shape = new Shape(Shapes.Html); //DEPRECARED;
            newIdea.Shape.TemplateId = "Circulargauge";
            newIdea.Email = "pepe";
            
           // newIdea.Type = Shapes.Html;

            //GaugeNode gaugeNode = new GaugeNode();
            //gaugeNode.Email = "papepepep";
            
            model.Nodes.Add(newIdea);             

ok, it's work. But when i try inspect new properties i can't find:



i can't find Email or Phone variable...

any idea? 



Shyam G [Syncfusion]
Replied On March 14, 2016 08:41 AM UTC

Hi David,

You have created a custom property by inheriting the node class, but we have some limitations as shown below.

Limitations:


1. The custom property gets serialized only if the default value and property value are different.

2. Also we have used this serializer to format the object to JSON data internally and send it from the server side to the client side. So if you need any additional features in this method it will not be implemented.


r
Instead of creating the custom property by inheriting the node class, please create an custom property for the node using node’s addInfo property. Please refer to the code example and sample below.

Code example:

  BasicShape node = new BasicShape();

   node.Name = name;

  Dictionary<string, object> addInfo = new Dictionary<string, object>();

  //add an custom property for the node

  addInfo.Add("email", "gs@gmail.com");

  addInfo.Add("phone", "99898989");
  node.AddInfo = addInfo;

//define click event
  model.Click = "click";

<script type="text/javascript">

    function click(args) {

        var node = args.element;

        if (args && args.element.type == "basic") {

            //get an custom property in the client side

            alert("email" + ":" + args.element.addInfo.email + "\n" + "phone" + ":" + args.element.addInfo.phone);

        }     

    }
</script>

Sample:http://www.syncfusion.com/downloads/support/forum/123378/ze/addInfoMVCsample-518592233

Regards,
Shyam G


David
Replied On March 14, 2016 09:01 AM UTC

Hi!

thanks for your response.

Please, can explain it:

The custom property gets serialized only if the default value and property value are different.

I try and don't work:
 private string gisEntitySubType;

        [JsonProperty("ngisEntitySubType")]
        [DefaultValue("")]
        public string GisEntitySubType
        {
            get { return gisEntitySubType; }
            set { gisEntitySubType = value; }
        }
        public GaugeNode()
        {
            this.GisEntitySubType = "juanito";
        }

Shyam G [Syncfusion]
Replied On March 15, 2016 05:40 AM UTC

Hi David,

Please use JsonProperty from Syncfusion namespace using Syncfusion.JavaScript.Shared.Serializer; instead of Newtonsoft namespace using Newtonsoft.Json; to resolve your reported issue. Please refer to the code example below and sample below.

Code example:

Namespace:
using Syncfusion.JavaScript.Shared.Serializer;

Sample:http://www.syncfusion.com/downloads/support/forum/123378/ze/custompropertysample-899531376

Regards,
Shyam G

David
Replied On March 15, 2016 08:54 AM UTC

oh...my fault...

thanks!

Shyam G [Syncfusion]
Replied On March 16, 2016 03:57 AM UTC

Hi David,

Please let me know if you need further assistance on this.

Regards,
Shyam G

David
Replied On March 16, 2016 08:45 AM UTC

It's OK.

Last question... What is better? use addInfo or use custom node

Shyam G [Syncfusion]
Replied On March 17, 2016 09:28 AM UTC

Hi David,


It is better to use addInfo instead of custom Node (custom property by inheriting the node class) because it has some limitations as mentioned earlier. 


Regards,

Shyam G 


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

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

;