|
Rank: Newbie Groups: Member
Joined: 1/4/2010 Posts: 5
|
I am trying to use a Context menu in TreeView and have run into a few issues:
1) My context menu shows up on right clicks outside of the TreeView area. Note that the ShowContextMenu function (see at end) is only invoked when clicking on a TreeNode. If clicking on a TreeNode, the correct menu shows up. If clicking on the TreeView in an area other than a TreeNode, no menu is displayed. I expected that returning false would display the standard IE right click menu. I also tried setting ContextControlID for the two menus to the clientID of the TreeView and that had no effect.
2) It appears that invoking edit requires a triple click, not the more common double click.
3) I am trying to invoke a rename/edit function from the context menu. I was unable to find a server side way to invoke this function, but I found a beginEdit method on the client side of a TreeNode. I cleared the Selected flag on all TreeNodes, then set selected on the ContextNode of the TreeView. After that I set the value of a hidden text element as a flag and included the below startup script on the page. Using the debugger, I determined that txt was being set correctly and that tv has a not null value. The problem is that getSelectedNode errors on invalid method. Any suggestions?
{ // startup code to see if we are editing var txt = document.getElementById("mrocontent$ctlCategories$txtEditSelected"); if (txt != null && txt.value != '') { txt.value = ''; var tv = document.getElementById("mrocontent_ctlCategories_tvCategories"); if (tv != null) { var tn = tv.getSelectedNode(); if (tn != null) tn.beginEdit(); } } }
function ShowContextMenu(e, treeView, node) { //Get the context menu object var bRet = false; var sType = node.getValue().substring(0, 2); if (sType == 'C_') { //Modify the context menu var menu = eo_GetObject("mrocontent_ctlCategories_pcmMenuCategory"); menu.getTopGroup().getItemByIndex(0).setText("Edit '" + node.getText() + "'"); menu.getTopGroup().getItemByIndex(1).setText("Delete '" + node.getText() + "'"); //Display the context menu. See documentation //for the Menu control for details about how //to handle menu item click event eo_ShowContextMenu(e, "mrocontent_ctlCategories_pcmMenuCategory"); bRet = true; } else if (sType == 'F_') { //Display the context menu. See documentation //for the Menu control for details about how //to handle menu item click event eo_ShowContextMenu(e, "mrocontent_ctlCategories_pcmMenuFeature"); bRet = true; }
//Returns true to indicate that we have //displayed a context menu return bRet; }
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,194
|
Hi, As to your questions: 1. There is no way to display the browser context menu if you click outside of a TreeNode but inside the TreeView once you have your context menu handler set; 2. We are not aware of this. You can check this sample and it takes a double click: http://demo.essentialobjects.com/Default.aspx?path=TreeView\_i1\_i43. You need to call eo_GetObject to get the TreeView object. It is a JavaScript object, not DHTML element. See here for more details: http://doc.essentialobjects.com/library/1/clientapi_howto.aspxThanks
|
|
Rank: Newbie Groups: Member
Joined: 1/4/2010 Posts: 5
|
1) I agree with your reply, but the context menu shows up when right-clicking outside of the TreeView control. I do not want it to. I can send a screen snap if that is helpful.
2) If you enable multiselect and DnD in the edit node demo, you will see the effect I described.
3) Thanks- that worked well.
4) I'm getting Javascript null errors on this.am, this.b and this.al. This appears to occur when clicking on another mode when ending an edit of a TreeNode. My TreeView is in a CallBackPanel and my treeview causes a postback to it when Rename is complete. What else can I give you to move forward on this?
<eo:TreeView ID="tvCategories" runat="server" ControlSkinID="MSDN" Height="100%" Width="100%" AllowDragDrop="True" AllowMultiSelect="True" ClientSideOnDragDrop="TreeDrop" OnItemMoved="tvCategories_ItemMoved" ClientSideOnNodeRename="TreeDrop" ClientSideOnContextMenu="ShowContextMenu" AllowEdit="False">
function cmdSaveClick() { eo_Callback('cbpCategories', ''); }
function TreeDrop() { setTimeout(cmdSaveClick, 10); }
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,194
|
Hi,
As to your questions:
#1. Check your ContextMenu's ContextControlID property. There is no reason for the context menu to automatically show up if you do not set that property;
#2. We still do not see this problem. Please check whether you are running the latest version;
#4. Please provide a full test page that demonstrates the problem. We will run the page and see if we can see the problem. As long as we can see it here, we should be able to tell you how to work around it;
Thanks!
|
|
Rank: Newbie Groups: Member
Joined: 1/4/2010 Posts: 5
|
1) Some days... I was using a PageContextMenu instead of a ContextMenu. That works correctly.
2 & 4) I've been diverted to another task. I'll bug you later if I still have an issue.
Thanks
|
|