Page Index Toggle Pages: 1 Send TopicPrint
Hot Topic (More than 10 Replies) Passing data from server to client side node (Read 5970 times)
Sheldon
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 15
Joined: Nov 20th, 2008
Passing data from server to client side node
Nov 21st, 2008 at 9:44pm
Print Post  
How can I pass a text string to some property of a ShapeNode that can be accessed by javascript when a user clicks the node?  (I do not wish this text to be displayed until the user clicks.)

I have been experimenting to see if I could at least display the node's label text in a popup box.  I have tried "args.getNode().getText();" which produces an "object required" error.

I have been working with NetDiagram for only a few days.  I'm enjoying learning NetDiagram and I hope someone can help me over this hump.

Thanks.

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


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Passing data from server to client side node
Reply #1 - Nov 22nd, 2008 at 12:20pm
Print Post  
You can use args.getNode.getText() only in JavaApplet mode. In ImageMap mode you can access only two properties of nodes - their ZIndex and their Tag. So you could set the text as a Tag value, and then get it using args.getNode().getTag() on the client side. Another option is to use ZIndex; it is unique for the items in the diagram, and you could pass is as an argument to a service through Ajax for ASP.NET. The service method could return any additional information you'd like to have on the client side.

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


I love YaBB 1G - SP1!

Posts: 15
Joined: Nov 20th, 2008
Re: Passing data from server to client side node
Reply #2 - Nov 22nd, 2008 at 7:50pm
Print Post  
Thank you once again, Stoyan. .getTag() is just what I was looking for, and I was pleased to see that it accepts arrays, which will be very useful to me.

I have also been unable to use the getMouseButton method, I suppose for the same reason. Is there a way to determine which mouse button was used without loading the java applet?
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Passing data from server to client side node
Reply #3 - Nov 23rd, 2008 at 9:54am
Print Post  
That's right, currently getMouseButton is not available in ImageMap mode. However, you could add your own handlers for every event raised for the node's AREA element, as explained here:
http://mindfusion.eu/Forum/YaBB.pl?board=fcnet_disc;action=display;num=122495953...

That will let you query the event object and check which button has been used, though you will have to take care of the difference between the browsers event models. The pre-release Netdiagram version posted in that thread might not be very stable, so don't use it on production servers.

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


I love YaBB 1G - SP1!

Posts: 15
Joined: Nov 20th, 2008
Re: Passing data from server to client side node
Reply #4 - Nov 24th, 2008 at 3:04pm
Print Post  
I'm unclear on how to use the CreateAreaElement event for my purpose, which is to launch one javascript function when the user left-clicks a node and a different javascript if the user right-clicks. A bit of sample code would be greatly appreciated.

Thanks.

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


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Passing data from server to client side node
Reply #5 - Nov 25th, 2008 at 7:03am
Print Post  
Add this to the aspx page:

Code
Select All
function onMouseDown(e)
{
	if (e.button == 2)
		alert("right button");
	else
		alert("another button");

	return false;
}
 



Different event models report different values for the button property of the event, and only 2 is the same in all models, meaning right button. You will have to add some browser detection code to differentiate between left and middle buttons.

Now you can handle CreatingArea like this:

Code
Select All
protected void view_CreatingAreaElement(object sender, CreatingAreaElementEventArgs e)
{
	e.Attributes["onmousedown"] = "return onMouseDown(event)";
}
 



Since you are generating the onMouseDown call on the server, you can pass any properties of the diagram item you'd like to the client-side function.

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


I love YaBB 1G - SP1!

Posts: 15
Joined: Nov 20th, 2008
Re: Passing data from server to client side node
Reply #6 - Nov 26th, 2008 at 3:13pm
Print Post  
I downloaded the files from the posting you directed me to and I substituted the three dll's in my bin folder with the new ones in the zip file.

I found that VWD would not accept the type "CreatingAreaElementEventArgs", so I defined e simply as an object in my vb code as follows:

Protected Sub DiagramView1_CreatingAreaElement(sender as object, e as object)

e.Attributes("onmousedown") = "return onMouseDown(event)"

End Sub

This compiled and ran without an error, but the code never executed. (I presume it's supposed to run each time a node or connector is created, is that right?)

Is there something else I should be doing to get this to run? I assumed that the object called "view" in the sample code is a DiagramView object, is that correct?
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Passing data from server to client side node
Reply #7 - Nov 26th, 2008 at 3:33pm
Print Post  
Can you see a CreatingAreaElement event defined for DiagramView? You will have to connect it with the DiagramView1_CreatingAreaElement handler method. The method should take a CreatingAreaElementEventArgs instance from the MindFusion.Diagramming.WebForms namespace, and not from a class defined by you. If you can't see such event, perhaps your project still refers to old version of the assemblies. Better delete them from the References section in Solution Explorer, and add the new ones using Add command in the References context menu.

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


I love YaBB 1G - SP1!

Posts: 15
Joined: Nov 20th, 2008
Re: Passing data from server to client side node
Reply #8 - Nov 27th, 2008 at 1:08am
Print Post  
I deleted the three dll's from the bin folder, as you suggested, and I re-referenced them, and now the "CreatingAreaElement" method does appear on the list of available methods for DiagramView1.

However, a new problem came up. When I try to run the file now, I get an error: "'TreeLayoutDirection' is not declared". You may recall that I had this problem earlier, and the solution was to add the line "Imports MindFusion.Diagramming.Layout".

Is there an additional Imports that I must add to regain access to TreeLayoutDirection?
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Passing data from server to client side node
Reply #9 - Nov 27th, 2008 at 6:35am
Print Post  
The TreeLayoutDirection enum has been renamed to TreeLayoutDirections.

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


I love YaBB 1G - SP1!

Posts: 15
Joined: Nov 20th, 2008
Re: Passing data from server to client side node
Reply #10 - Nov 27th, 2008 at 4:30pm
Print Post  
Thank you, Stoyan.  I believe I now have all the info I need to get started.  I appreciate yor help very much.

Sheldon
  
Back to top
 
IP Logged
 
Sheldon
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 15
Joined: Nov 20th, 2008
Re: Passing data from server to client side node
Reply #11 - Dec 1st, 2008 at 1:49am
Print Post  
One more related question, Stoyan, if I may...

Is it possible, in ImageMap mode, to alter the backcolor or font or some other attribute to indicate that the node just clicked has been selected?
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Passing data from server to client side node
Reply #12 - Dec 1st, 2008 at 10:20am
Print Post  
AFAIK, this can be done only on the server side when using image map mode. You could put the DiagramView inside an UpdatePanel to prevent postback of the whole page, and only the diagram image will be refreshed.

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