This is a migrated thread and some comments may be shown as answers.

Renaming a node by right click (only)

1 Answer 74 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
Jeppe
Top achievements
Rank 1
Jeppe asked on 27 Feb 2009, 03:49 AM
Hi

Is it possible to enable renaming only by right clicking ?

So instead of going into edit mode when clicking twice it will unselect the node on second click.

1 Answer, 1 is accepted

Sort by
0
Jeppe
Top achievements
Rank 1
answered on 27 Feb 2009, 05:07 AM
I figured it out. In case anyone out there found it very exiciting, here it is.

First I turned off node editing in the treeview.

 AllowNodeEditing="False" 

Then caught the right clicking.

function OnClientContextMenuItemClicking(sender, eventArgs) 
    var menuItem = eventArgs.get_menuItem(); 
    var treeNode = eventArgs.get_node(); 
 
    switch(menuItem.get_value()) 
    { 
        case "Rename"
            treeNode.get_treeView()._startEdit(treeNode); 
            eventArgs.set_cancel(true); 
            menuItem.get_menu().hide();   
            break;   
    } 

Then I wanted to unselect a node if it was already selected

function OnClientNodeClicking(sender, eventArgs) 
    var treeNode = eventArgs.get_node(); 
     
    if(treeNode.get_selected() == true ) 
    { 
        treeNode.set_selected(false); 
        treeNode.unhighlight(); 
        eventArgs.set_cancel(true); 
    } 






Tags
TreeView
Asked by
Jeppe
Top achievements
Rank 1
Answers by
Jeppe
Top achievements
Rank 1
Share this question
or