Page Index Toggle Pages: 1 [2]  Send TopicPrint
Hot Topic (More than 10 Replies) custom propeties (Read 10457 times)
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: custom propeties
Reply #15 - Oct 2nd, 2009 at 9:31am
Print Post  
Change the server-side SerializeTag handler to this:

Code
Select All
void diagram_SerializeTag(object sender, SerializeTagEventArgs e)
{
	Dictionary<string, string> table = (Dictionary<string, string>)e.Tag;
	string[] serialized = new string[table.Count * 2];
	int c = 0;
	foreach (KeyValuePair<string, string> p in table)
	{
		serialized[c++] = p.Key;
		serialized[c++] = p.Value;
	}
	e.Representation.InnerText = String.Join(";", serialized);

	e.Handled = true;
}
 



and on the client side add this function as DeserializeTagScript:

Code
Select All
function onDeserializeTag(tagString)
{
	var strings = tagString.split(";");
	var customProps = new Object();

	for (i = 0; i < strings.length; i += 2)
		customProps[strings[i]] = strings[i + 1];

	return customProps;
}
 

  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: custom propeties
Reply #16 - Oct 2nd, 2009 at 9:33am
Print Post  
and now if you call node.getTag() on the client side, you will get a JS object whose properties and values can be enumerated like this

Code
Select All
for (var property in tag)
{
	if (tag.hasOwnProperty(property))
		document.write(property + " " + tag[property];
}
 

  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1 [2] 
Send TopicPrint