Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic Store Custom Data with the Tag of a ShapeNode (Read 3476 times)
Anoop C M
YaBB Newbies
*
Offline


I Love MindFusion!

Posts: 3
Joined: Jan 4th, 2013
Store Custom Data with the Tag of a ShapeNode
Jan 4th, 2013 at 10:22pm
Print Post  
I wanted to store some custom data as json object to each of the nodes. I tried to use the Tag object but apparently it failed with a message "split" function not found.
How can we do this?

Also as I see the Tag is currently used to show the title in the NodeListView. Can we have a seperate object property to store custom data.


I know Diagram  has the SerializeTag/DeserializeTag but that is only useful for Saving/Loading. 
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Store Custom Data with the Tag of a ShapeNode
Reply #1 - Jan 7th, 2013 at 9:23am
Print Post  
For items in the diagram you can set Tag to any object with simple values; they will be serialized to Json automatically by the framework's built-in JavaScriptSerializer.

Code
Select All
// on server
node.Tag = new { Prop1 = "Val1", Prop2 = "Val2" };

// on client
function onNodeClicked(sender, args)
{
    alert(args.getNode().getTag().Prop1);
} 



Indeed the NodeListView uses Tag to transfer caption values to the client side, so you can't assign tags to its nodes at this time. We'll add a separate property for captions in the next release.

I hope that helps,
Stoyan
  
Back to top
 
IP Logged
 
Anoop C M
YaBB Newbies
*
Offline


I Love MindFusion!

Posts: 3
Joined: Jan 4th, 2013
Re: Store Custom Data with the Tag of a ShapeNode
Reply #2 - Jan 7th, 2013 at 4:29pm
Print Post  
Thanks Stoyan. That helps confirm.

If you set the tag for the NodeListView then it fails so it is a bug right now. Good to hear that you will proactively add a new property to fix it.

Thanks
Anoop
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint