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

[Solved] Editing Node via Context Menu

3 Answers 245 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
rsterba
Top achievements
Rank 1
rsterba asked on 09 Apr 2008, 08:04 PM
I have created a context menu for my Tree View, and one of the items is an edit command.  With javascript, I am able to toggle the startEdit() command, and the node will go into edit mode.  However, almost instantly, the node will exit edit mode.

javascript:
<script type="text/javascript"
     function onClientContextMenuItemClicked(sender, args) 
                { 
                    var menuItem = args.get_menuItem(); 
                    var treeNode = args.get_node(); 
 
                    switch(menuItem.get_value()) 
                    { 
                        case "Edit"
                            treeNode.get_treeView()._startEdit(treeNode); 
                            break
                    } 
                } 
    </script> 

ASPX:

<telerik:RadTreeView OnClientContextMenuItemClicked="onClientContextMenuItemClicked" ...> 
   <ContextMenus> 
      <telerik:RadTreeViewContextMenu ...> 
         <Items> 
            <telerik:RadMenuItem runat="server" ExpandMode="ClientSide" Value="Edit" Text="Edit Node"
               <GroupSettings ExpandDirection="Auto" Flow="Vertical" /> 
            </telerik:RadMenuItem> 
         </Items> 

Does anyone have any idea what the problem could be?  This code is near cut-and-paste from the Prometheus examples.

Edit: It's also probably worth of note that the RadTreeView is wrapped inside a RadPane, which is inside a RadSplitter, inside of an UpdatePanel ^^;

3 Answers, 1 is accepted

Sort by
0
Simon
Telerik team
answered on 14 Apr 2008, 11:04 AM
Hello rsterba,

I tried using both RadTreeView._startEdit(RadTreeNode) and RadTreeNode.startNode() client-side functions and Node Editing worked as expected.

Please find attached the page demonstrating this.

I suppose there is something else going on on the page, some other javascript which executes and it stops the editing.

Could you post any other javascript code which executes on the page?

Sincerely yours,
Simon
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
rsterba
Top achievements
Rank 1
answered on 14 Apr 2008, 04:18 PM
Simon,

I have discovered the issue causing this unexpected behavior, but am unsure how to work around it.  The context menu I've created has multiple options: Add, Edit, and Delete.  However, each of the items in my RadTreeView is associated with a strongly typed object from my data source.  In order to add, edit, or delete these I must execute a server-side event RadTreeView1_ContextMenuItemClick.  It is this event that is causing the client-side edit to stop.

That being said, is there any way (on server-side) to toggle a node into edit mode?
0
Simon
Telerik team
answered on 17 Apr 2008, 02:45 PM
Hello rsterba,

Have you considered emitting JavaScript code from the server by using the RegisterStartupScript() method?

The client code could find the specific node by value and call its startEdit() function.

I hope this helps.

Kind regards,
Simon
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
Tags
TreeView
Asked by
rsterba
Top achievements
Rank 1
Answers by
Simon
Telerik team
rsterba
Top achievements
Rank 1
Share this question
or