How let user rename node client-side

5 posts, 0 answers
  1. Al
    Al avatar
    216 posts
    Member since:
    Oct 2006

    Posted 10 Nov 2016 Link to this post

    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();
    }
  2. Al
    Al avatar
    216 posts
    Member since:
    Oct 2006

    Posted 10 Nov 2016 Link to this post

    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();
    }
  3. Ivan Danchev
    Admin
    Ivan Danchev avatar
    1253 posts

    Posted 14 Nov 2016 Link to this post

    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.
  4. Al
    Al avatar
    216 posts
    Member since:
    Oct 2006

    Posted 14 Nov 2016 in reply to Ivan Danchev Link to this post

    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?
  5. Ivan Danchev
    Admin
    Ivan Danchev avatar
    1253 posts

    Posted 15 Nov 2016 Link to this post

    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.
Back to Top