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

How let user rename node client-side

4 Answers 10 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
Al
Top achievements
Rank 1
Iron
Iron
Veteran
Al asked on 10 Nov 2016, 12:48 PM

Hi,

I have a "Rneame" context menu on my treeview that gets handled client-side and initiates node.startEdit(); The node goes into edit mode & the user can edit the text and hit enter and all looks fine on-screen.

The problem come during postback though - the node in code-behind still has the old name?

 

function tvwListData_ClientContextMenuItemClick(sender, args) {
 
    var tree = $find("<%= tvwListData.ClientID %>");           
    var node = args.get_node();           
 
    tree.trackChanges();
 
    var item = args.get_menuItem();
    switch (item.get_value()) {
 
        case "Rename":
            node.startEdit();
            break;
 
        case "Delete":
            node.get_parent().get_nodes().remove(node);
            break;
    }           
    tree.commitChanges();
}

4 Answers, 1 is accepted

Sort by
0
Al
Top achievements
Rank 1
Iron
Iron
Veteran
answered on 10 Nov 2016, 12:53 PM

I think I found my problem - I need to commit changes to the tree after the node is edited:

 

function tvwListData_ClientNodeEdited(sender, args) {
    sender.commitChanges();
}
0
Ivan Danchev
Telerik team
answered on 14 Nov 2016, 02:12 PM
Hello Alwin,

Indeed the TreeView's commitChanges method needs to be called after the changes are made, in order for them to be persisted on the server. Calling the method in the OnClientNodeEdited event's handler is correct, since the event fires when the node's text editing is complete.

Regards,
Ivan Danchev
Telerik by Progress
Check out the new UI for ASP.NET Core, the most complete UI suite for ASP.NET Core development on the market, with 60+ tried-and-tested widgets, based on Kendo UI.
0
Al
Top achievements
Rank 1
Iron
Iron
Veteran
answered on 14 Nov 2016, 02:19 PM
Thanks Ivan. It does seem to work fine though when I call it in that event - which event should I use if that is not the correct one?
0
Ivan Danchev
Telerik team
answered on 15 Nov 2016, 11:55 AM
Hi Alwin,

It is the correct event, if tvwListData_ClientNodeEdited is the handler of the OnClientNodeEdited event, which I assume it is judging by the handler's name, then that is the proper place to call the method. 

Regards,
Ivan Danchev
Telerik by Progress
Check out the new UI for ASP.NET Core, the most complete UI suite for ASP.NET Core development on the market, with 60+ tried-and-tested widgets, based on Kendo UI.
Tags
TreeView
Asked by
Al
Top achievements
Rank 1
Iron
Iron
Veteran
Answers by
Al
Top achievements
Rank 1
Iron
Iron
Veteran
Ivan Danchev
Telerik team
Share this question
or