Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New to the CF scene
    Join Date
    Jan 2007
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question Adding right-click ability and pop-up menu to a Treeview

    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.

  • #2
    Regular Coder
    Join Date
    May 2005
    Location
    Michigan, USA
    Posts
    566
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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.
    Note: I do not test code. I just write it off the top of my head. There might be bugs in it! But if any thing I gave you the overall theory of what you need to accomplish. Also there are plenty of other ways to accomplish this same thing. I just gave one example of it. Other ways might be faster and more efficient.

  • #3
    New to the CF scene
    Join Date
    Jan 2007
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Exclamation

    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


    Quote Originally Posted by utkuozan View Post
    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.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •