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
close icon

How to use AddInfo

Hi, can you give me some guidance on how to use the AddInfo property of nodes?

  1. How to add items to AddInfo in MVC/.NET
  2. How to retrieve the values in JavaScript

Thanks for your help.


6 Replies

JE Jeff August 28, 2014 05:11 AM UTC

Ooops.  I meant to put this in the ASP.NET MVC forum.  Could you move it for me?  Sorry, and thank you.



SG Shyam G Syncfusion Team August 28, 2014 05:34 AM UTC

Hi Jeff

Thanks for using Syncfusion products.

 

Query

Response

Hi, can you give me some guidance on how to use the AddInfo property of nodes?

1.       How to add items to AddInfo in MVC/.NET

2.       How to retrieve the values in JavaScript

Thanks for your help.

We have created a simple sample to meet your requirement and attached below. Please see the code snippet below.

 

//add items to addinfo

          Node add = CreateNode("add", 150, 50, 200, 200, "add");

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

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

            add.AddInfo = addInfo;

            model.Nodes.Add(add);

 

function onclick(args) {

           var diagram = $("#Diagram1").ejDiagram("instance");

           if (args.element.shape) {

              

//retreiving addinfo values in javascript

 

 var addinfo = args.element.addInfo.email;

           alert(addinfo);

        }

    }

 

Please let me know if any concerns.

Regards,

Shyam G


Attachment: addinfo_42671972.zip


JE Jeff August 28, 2014 10:57 PM UTC

Thanks for the sample.  That worked well.



SG Shyam G Syncfusion Team September 1, 2014 03:50 AM UTC

Hi Jeff,

Thanks for your reply.

We are happy to hear that the problem is resolved.

Regards,

Shyam G



GG Gyorgy Gorog May 18, 2018 11:44 AM UTC

Hi, at least in the present version js args.element.addinfo does not seem to exist. I tried .element.attributes.getNamedItem() but failed. Please advise.


SG Shyam G Syncfusion Team May 21, 2018 04:44 AM UTC

Hi Gyorgy Gorog, 
 
We have created a MVC sample in which we have set an addInfo property for nodes and retrieved it in the client side(.cshtml file) using click event. Please refer to the code example and sample below. 
 
Code example: 
 
DiagramController.cs 
 
  BasicShape node = new BasicShape(); 
   //create addInfo property for node 
   Dictionary<string, object> addInfo = new Dictionary<string, object>(); 
   addInfo.Add("email", "ram@gmail.com"); 
   node.AddInfo = addInfo; 
   Diagram.Nodes.Add(node); 
 
  //define click event 
  Diagram.Click = "click"; 
 
  function click(args) { 
        if (args.element) { 
            if (args.element.addInfo) { 
                             //retrieve addInfo property 
                alert(args.element.addInfo.email); 
            } 
        } 
    } 
 
 
Regards, 
Shyam G 


Loader.
Live Chat Icon For mobile
Up arrow icon