Home - Forums-.NET - FlyTreeView (ASP.NET) - FlyContextMenu

FlyTreeView (ASP.NET)

Technical support and KB related to the FlyTreeView control

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

FlyContextMenu
Link Posted: 30-Aug-2007 21:01
How to get selected node text

and put it in menuitem text ?



Delete (+ selected node text) \" AutoPostBack=\"True\" CommandName=\"delete\" />





Menu is rebuilt after SelectedNodeChanged:

switch (e.Node.Level)

{

case 0:

FlyTreeView1.ContextMenuID = \"ContextMenu1\";

break;

case 1:

FlyTreeView1.ContextMenuID = \"ContextMenu2\";

break;

case 2:

FlyTreeView1.ContextMenuID = \"ContextMenu3\";

break;

}





Thanks in advance.
Link Posted: 30-Aug-2007 22:11
Do you actually need to postback treeview when selecting some node.

From my point of view, you can change contetx menu item text at client-side.

Using the OnContextMenuJavascript handler.

You can refer to default Demo_Office2003.aspx source code and specially the  code:

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();
    for(var i = 0; i < items.length; i++) {
        switch(items[i].getCommandName()) {
            case \"Expand\":
                items[i].setDisabled(!expandEnabled);
                break;
            case \"Collapse\":
                items[i].setDisabled(!collapseEnabled);
                break;
        }
    }
    
}


Actually it just enables/disables some menu items.
But you can simply modify it in order to use
items[i].setText(\"Delete \" + node.getText());

Or something like this.