OnNodeEdit not triggered correctly in public Demo

6 posts, 0 answers
  1. Per
    Per avatar
    116 posts
    Member since:
    Jan 2008

    Posted 15 Aug 2013 Link to this post

    Hi!

    I might have found a bug in your demo application and this bug is also haunting my application.
    In the demo, found here: http://demos.telerik.com/aspnet-ajax/treeview/examples/functionality/contextmenu/defaultcs.aspx.,
    you can right clikc on a node and create a new folder.

    Now, if you change the default text, a postback will occure and the server side event "OnNodeEdit" will be triggered. But, if you dont change the text and just press enter, no server side event will occure and the node will not be saved.

    How do I fix this?

    Regards,
    Per
  2. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 20 Aug 2013 Link to this post

    Hi Per,

    This is the expected behavior and not a bug. After you have typed the new text, click outside the tree or press the Enter key. Then only the NodeEdit server event will be fired. In your particular scenario, the "New Folder" text is the original text and on pressing Enter Key without modifying the text, the node is treated as not edited and hence the event is not fired.

    Thanks,
    Shinu.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Per
    Per avatar
    116 posts
    Member since:
    Jan 2008

    Posted 23 Aug 2013 Link to this post

    Hi!

    But how do you know when a user adds a new node and exit editing without changing anything?
    It looks to the user as the node has been created with the default name, but It hasn't.

    Lets say you want to supply a meaningfull default node name to the user so he/she doesn't need to change it.
    How do you capture this in your backend?

    Regards,
    Per
  5. Hristo Valyavicharski
    Admin
    Hristo Valyavicharski avatar
    975 posts

    Posted 28 Aug 2013 Link to this post

    Hi Per,

    The default text is actually the text on the newly added node:
    case "NewFolder":
                    RadTreeNode newFolder = new RadTreeNode(string.Format("New Folder {0}", clickedNode.Nodes.Count + 1));
                    newFolder.Selected = true;

    To determine if the default node's text has been changed, you may use something similar to this:
    protected void RadTreeView1_NodeCreated(object sender, RadTreeNodeEventArgs e)
    {
        //Check if default text is changed
        if (e.Node.Text == "New Folder 1")
        {
            ...
        }
    }

    Regards,
    Hristo Valyavicharski
    Telerik
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to the blog feed now.
  6. Per
    Per avatar
    116 posts
    Member since:
    Jan 2008

    Posted 04 Sep 2013 Link to this post

    Hi again Okey, now I know how to check if the text has not been changed when I create a new node. Now I just need the treeview to fire the server side event "OnNodeEdit". Any ideas on how to do this? Regard Per
  7. Boyan Dimitrov
    Admin
    Boyan Dimitrov avatar
    1746 posts

    Posted 09 Sep 2013 Link to this post

    Hello Per,

    I would like to clarify that from the code behind you can simply find the RadTreeView node object and set new text value using the .Text property of the node object.
    //code behind

    protected void RadTreeView1_NodeClick(object sender, RadTreeNodeEventArgs e)
            {
                e.Node.Text = "sample text";
            }


    Regards,
    Boyan Dimitrov
    Telerik
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to the blog feed now.
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017