Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic How to put data in HTML5 data attribute (Read 5229 times)
mandz
YaBB Newbies
*
Offline


I Love MindFusion!

Posts: 28
Joined: Mar 12th, 2013
How to put data in HTML5 data attribute
Apr 16th, 2013 at 12:07am
Print Post  
Hi there,

I would like to save values in the HTML5 data attribute of a node using C#. I'm using a ShapeNode.  Values can be i.e. the database ID of the node.  How can I do that?

I'm starting to wonder if it isn't better to 'draw' the diagram in the ready() event so that it is drawn by the browser as opposed to the server using client code.  That would easily solve my question above.  But then I might as well use the Javascript components and not the MVC (I think).  Or should I use MVC and only use client code?  I can pass in my viewmodel and have Javascript code handle everything.  You don't have any examples of that, but I think I can work it out. 

Have you done any performance tests between having the server draw the diagram and the client do it?  How does it compare?

I know I'm asking more than one question, but I think it's a bit related.

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


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: How to put data in HTML5 data attribute
Reply #1 - Apr 16th, 2013 at 7:21am
Print Post  
Hi,

Quote:
I would like to save values in the HTML5 data attribute of a node using C#. I'm using a ShapeNode. Values can be i.e. the database ID of the node. How can I do that?


There aren't any HTML DOM elements associated with nodes on the client side, so no HTML5 data attributes either. The diagram items are JavaScript objects that can draw themselves on a Canvas element. You can associate custom data with nodes by setting their Tag or Id property on server, and access it via getTag() and getId() on client side.

Quote:
I'm starting to wonder if it isn't better to 'draw' the diagram in the ready() event so that it is drawn by the browser as opposed to the server using client code. That would easily solve my question above. But then I might as well use the Javascript components and not the MVC (I think). Or should I use MVC and only use client code? I can pass in my viewmodel and have Javascript code handle everything. You don't have any examples of that, but I think I can work it out.


There's nothing wrong with building the diagram on the client side, most of the API is available in JavaScript too. You could also save some bandwidth that way by sending only your bare-bones model data instead of the diagram JSON arrays containing all attributes of nodes and links. You can find some examples and tutorials that build diagrams in JavaScript coming with our standalone JavaScript library:
http://mindfusion.eu/onlinedemo-jsdiagram.html
http://www.mindfusion.eu/onlinehelp/jsdiagram/index.htm?CC_Tutorial_1__Loading_G...

Quote:
Have you done any performance tests between having the server draw the diagram and the client do it? How does it compare?


JavaScript is still much slower than the .NET runtime and some operations will run faster on the server, e.g. automatic graph layout algorithms. If you expect many users running graph layouts at the same time, you might still want to offload them to client side though, or your server could crash Wink

I hope that helps,
Stoyan
  
Back to top
 
IP Logged
 
mandz
YaBB Newbies
*
Offline


I Love MindFusion!

Posts: 28
Joined: Mar 12th, 2013
Re: How to put data in HTML5 data attribute
Reply #2 - Apr 16th, 2013 at 11:39pm
Print Post  
Thank you Stoyan.  It's really helpful.  But I want to ask one more question though.  I'm a bit of a newby when it gets to web development (you can probably already tell).  I'm more of a WPF developer.

What really is the difference between using the client side MVC controls and the Javascript controls?  Should I be looking at the Javascript reference/documentation or the MVC client side Reference?  Both are Javascript, aren't they?
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: How to put data in HTML5 data attribute
Reply #3 - Apr 17th, 2013 at 5:57am
Print Post  
There isn't any difference if you'll be developing in JavaScript. That same JavaScript library is also included as part of our ASP.NET and ASP.NET MVC controls and the client side API reference in their help files is just a copy of the stand-alone JavaScript library reference.

I hope that helps,
Stoyan
  
Back to top
 
IP Logged
 
mandz
YaBB Newbies
*
Offline


I Love MindFusion!

Posts: 28
Joined: Mar 12th, 2013
Re: How to put data in HTML5 data attribute
Reply #4 - Apr 17th, 2013 at 11:54pm
Print Post  
Thanks.  I'll be buying the MVC controls then.
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint