...

View Full Version : Adding right-click ability and pop-up menu to a Treeview



utkuozan
01-04-2007, 09:25 AM
I have a treeview created as an ASP object on my form, populated with many items hierarchically. I want to add a pop-up menu which will appear when a node is right-clicked and show related operations that could be done on this node.

Creating TreeView is no problem. I can also create a pop-up menu with javascript and styles. But the thing is that TreeView does not have onClick event. Most probable answer is onSelectedNodeChanged event bu when I right-click a node on TreeView the javascript code about the pop-up menu fires first and besides the right clik event -of course- does not fire the onSelectedNodeChanged event.

On such conditions I first have to select a node and then right click it.

How can I possibly overcome this problem? The problem is basically that I want to change the SelectedNode while ı am right-clicking and then run a javascript to show a pop-up menu.

Regards.

SpirtOfGrandeur
01-09-2007, 12:44 PM
You are not going to want to do this inside of ASP.Net. You are going to want to handle this inside of JS. I will give you the idea and then you can go ahead and play with it a bit and see if you can get it to work.

You want to create a function that on window load (window.onload) finds the div that is holding the treeview (usualy something like 'TreeView1'). You want to grab all the cells (<td>) from inside the div and hook a right click function to them. Then you can go ahead and show the popup on the right click and allow the left click on the image or link to be handled normally by the code.

I hope this makes sense. I do not have the time to code it but I am sure some one might if this gets moved over to the JS forum.

ny_shock
01-12-2007, 05:10 PM
utkuozan,

If you find a solution or would like to collaborate on creating a treeview popop menu please contact me.

anybody else , feel free to join!

nyck



I have a treeview created as an ASP object on my form, populated with many items hierarchically. I want to add a pop-up menu which will appear when a node is right-clicked and show related operations that could be done on this node.

Creating TreeView is no problem. I can also create a pop-up menu with javascript and styles. But the thing is that TreeView does not have onClick event. Most probable answer is onSelectedNodeChanged event bu when I right-click a node on TreeView the javascript code about the pop-up menu fires first and besides the right clik event -of course- does not fire the onSelectedNodeChanged event.

On such conditions I first have to select a node and then right click it.

How can I possibly overcome this problem? The problem is basically that I want to change the SelectedNode while ı am right-clicking and then run a javascript to show a pop-up menu.

Regards.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum