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
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
5 Answers, 1 is accepted
0
Shinu
Top achievements
Rank 2
answered on 20 Aug 2013, 07:22 AM
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.
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.
0
Per
Top achievements
Rank 1
answered on 23 Aug 2013, 12:28 PM
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
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
0
Hi Per,
The default text is actually the text on the newly added node:
To determine if the default node's text has been changed, you may use something similar to this:
Regards,
Hristo Valyavicharski
Telerik
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.
0
Per
Top achievements
Rank 1
answered on 04 Sep 2013, 04:10 PM
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
0
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
Regards,
Boyan Dimitrov
Telerik
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.