Home - Forums-.NET - FlyTreeView (ASP.NET) - Problems in using Context Menu

FlyTreeView (ASP.NET)

Technical support and KB related to the FlyTreeView control

This forum related to following products: FlyTreeView for ASP.NET

Problems in using Context Menu
Link Posted: 12-Apr-2007 01:03
Hi, I am facing the following problems in using Context Menu: 1.) ContextMenu is displayed only for the first time when I right click on a node, however if I select a particular node, and after that I right click on any node, Context Menu is not displayed. 2.) When user clicks on an Item in Context Menu, I need to node through which node that Context Menu was clicked. For this is it necessary that I make the user to select that node ? I will really appreciate if someone can help in resolving above issues. Warm regards, Shantanu [code] <%@ Register Assembly=\"NineRays.WebControls.FlyTreeView\" Namespace=\"NineRays.WebControls\" TagPrefix=\"nr\" %> void myMenu_Command(object sender, FlyContextMenuCommandEventArgs e) { Button1.Text = \"Menu Clicked\"; } protected void tree_SelectedNodeChanged(object sender, SelectedNodeChangedEventArgs e) { Button1.Text = e.Node.Text + \" was selected\"; } Untitled Page
   
[/code][/list]
Link Posted: 12-Apr-2007 03:51
I think I have a similar problem to the one listed above.  Both my TreeView and ContextMenu exist in the same update panel.  My TreeView nodes are set to PostBack on Select.  Here is what happens:

Page Loads - all is fine, right click pulls up context menu on nodes, I can expand and collapse (expand on select is FALSE).  When I select a node (a subsequently postback) the context menu stops functioning.

I think this is similar behaviour to the poster above.  I don't want to hijack his question but perhaps the answer will suit both of us.

Thanks,

Matt.



function HandleContextMenuPopup(sender, node, event)
{
    var nodeContextMenuID = node.getContextMenuID();
    if (node.getContextMenuID().length == 0) return;
    
    var expandEnabled = node.getChildNodes().length > 0 && !node.getExpanded();
    var collapseEnabled = node.getChildNodes().length > 0 && node.getExpanded();
    
    var contextMenu = CFlyContextMenu.getInstanceById(\"\");
    var items = contextMenu.getItems();
    var nodeDepth = node.getLevel();
    
    
  Just enabled/disables items based on the node on right-click.
  
}
function ExpandNode(item, argument)
{
    var node = argument;
    node.expand();
}
function CollapseNode(item, argument)
{
    var node = argument;
    node.collapse();
}
function DeleteNode(item, argument)
{
    var node = argument;
    if (confirm(\"Are you sure want to delete node \" + node.getValue()))
        node.remove();
}


  
    
      
    
    
      
        
        
        
        
      
    
  

Link Posted: 12-Apr-2007 08:01
[quote="shantanukagg"]
1.) ContextMenu is displayed only for the first time when I right click on a node, however if I select a particular node, and after that I right click on any node, Context Menu is not displayed.

Yes, we have this issue with the Context Menu + UpdatePanel.  Hope to get it solved and released in two days.

[quote="shantanukagg"]
2.) When user clicks on an Item in Context Menu, I need to node through which node that Context Menu was clicked. For this is it necessary that I make the user to select that node ?

No, you do not have to select node. FlyContextMenu event handler - Command - uses FlyContextMenuCommandEventArgs arguments.
Use FlyContextMenuCommandEventArgs.CommandArgument to get node ID.
So your handler code should look like this:
void myMenu_Command(object sender,
FlyContextMenuCommandEventArgs e)
{
    Button1.Text = "Menu Clicked";
    FlyTreeNode node = tree.FindByID(e.CommandArgument);
}
Link Posted: 12-Apr-2007 08:02
[quote="matt"]I think this is similar behaviour to the poster above.  I don't want to hijack his question but perhaps the answer will suit both of us.

Yes, matt, this is a known issue now and we're going to release a fixed version ASAP.
Link Posted: 12-Apr-2007 08:19
Thanks !

I am waiting eagerly for the release of fixed version.

However, I am not sure but can this functionality be provided using FlyTreeView ?
Manual editing of TreeNode label by user. I mean, just to provide a complete desktop experience, I would like to incorporate something, by which the user can edit the TreeNode Label ( I know its possible using Windows.Form). Something Like clicking on context menu, option for renaming comes & when user selects that the TreeNode Label becomes editable.

Please Let me know if anything is there which can help me in this.

Warm regards,
Shantanu
Link Posted: 12-Apr-2007 08:35
Node text can be changed. But this will require a popup dialog (built into javascript).

You can see sample implementation at:

http://www.9rays.net/asp.net_2/treeview/Demo_ClientModel.aspx

See the  \"setText(value) call this method\" row. Click \"call this..\".

It changes text for selected node. But the same way you can use context menu to edit text, since any context menu item can contain javascript handler.
Link Posted: 16-Apr-2007 11:38
New version containing context menu fix is available for download at

http://www.9rays.net/download.aspx?productFamily=TreeView_ASP.NET_2