Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic How to add a custom XML node from JavaScript (Read 4080 times)
khurramdbg
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 8
Joined: Mar 29th, 2010
How to add a custom XML node from JavaScript
Mar 29th, 2010 at 10:05am
Print Post  
plz help me ...

i m trying to add a custom XML node from the javascript. i m using this syntax

node.setTag(<Time>2</Time>)

but no success it adds a tag in xml with different name... like <tag Type="2' ,..... etc

plz help me.. i m using JavaApplet as output.
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: How to add a custom XML node from JavaScript
Reply #1 - Mar 29th, 2010 at 11:28am
Print Post  
Unfortunately that's not supported. You can assign arbitrary objects to the Tag property, but the SerializeTag handler must encode them as simple strings when submitting to the server. E.g. you might concatenate all attributes of an object into a string containing comma-delimited list.

Stoyan
  
Back to top
 
IP Logged
 
svendazjer
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 5
Joined: Oct 8th, 2010
Re: How to add a custom XML node from JavaScript
Reply #2 - Oct 13th, 2010 at 6:08pm
Print Post  
Can I change the type of the node?, I would like to do something like:

<Tag Type="MyType">MyNodeContent</Tag>
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: How to add a custom XML node from JavaScript
Reply #3 - Oct 13th, 2010 at 7:05pm
Print Post  
Sorry, what's exposed to the applet works only with strings at this time. If you know some Java you could implement DiagramListener.serializeTag / deserializeTag methods to get access to the XML DOM.
  
Back to top
 
IP Logged
 
svendazjer
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 5
Joined: Oct 8th, 2010
Re: How to add a custom XML node from JavaScript
Reply #4 - Oct 13th, 2010 at 7:13pm
Print Post  
I working with C#...

If you know some way that I could set my own tags or set the type to the Tag node I would really appreciate.

thanks in advance
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: How to add a custom XML node from JavaScript
Reply #5 - Oct 13th, 2010 at 7:44pm
Print Post  
Are you using JavaApplet mode and need to access the tags on the client side, or you only need their values preserved between post-backs?
  
Back to top
 
IP Logged
 
svendazjer
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 5
Joined: Oct 8th, 2010
Re: How to add a custom XML node from JavaScript
Reply #6 - Oct 14th, 2010 at 3:35pm
Print Post  
I'm sorry, I believe I post in the wrong thread, but I believe you can still help me, I'm not using JavaApplet at all, I'm just have my windows app build in C#, and what I need is to save the project to an xml but with some custom nodes, I figure out that cannot be done, so I found that I could use the <Tag> node to do that, so, in order to do custom node I tryng to set a custom Type Tag.

I doing this: diagram.Tag="MyCustomContent";

but also I need to idenfied that node, and with the standard type that use numbers it's almost like I'm not customizing at all...

what I need to do is set a custom type, like I posted before:

<Tag Type="MyType">MyNodeContent</Tag>

I hope you can help me.

thanks. Svendazjer
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: How to add a custom XML node from JavaScript
Reply #7 - Oct 14th, 2010 at 4:20pm
Print Post  
Ok, that can be done by handling the SerializeTag event. Note that it is raised only if DiagramItem.Tag is not null. You must also set e.Handled = true to keep your custom XML, or otherwise the control would overwrite it using the built-in serialization. You can find sample code in the Diagram.SerializeTag Event help topic. Args.Representation would point to the "Tag" Xml node, and you could set attributes on it too.

Another possibility is to use a derived node type and override its SaveToXml method. This would let you add child elements directly under <Node>, instead of deeper in the hierarchy under <Tag>.

I hope that helps,
Stoyan
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint