I am trying to perform some simple data validation of the nodes on client-side editing. The purpose is to disallow two items with the same parent and matching names. I handle OnClientNodeEditing and, if the validation fails, call startEdit() of the edited node.
Calling startEdit() shows an edit element on top of the node, looking like a standard EditBox element, not the usual behavior when editing a node. Apart from that, the text in that edit box is selected and can be edited, but pressing Enter or clicking outside the node doesn't cancel edit mode, but does its normal behavior (for example, if clicking on another node, its NodeClick event is fired). Keyboard focus is also not in that edit box element, but on the tree, so pressing the arrow keys navigates trough the nodes instead of moving the cursor inside the edit box.
If I try to end edit mode with node.endEdit() before starting startEdit() again, it throws a null reference error.
| function RadTreeView1_OnClientNodeEditing(sender, eventArgs) |
| { |
| var node = eventArgs.get_node(); |
| var oldText = node.get_text(); |
| var newText = eventArgs.get_newText(); |
| var siblings = node.get_parent().get_nodes(); |
| for(i = 0; i < siblings.get_count(); i++) |
| { |
| var currNode = siblings.getNode(i); |
| if(currNode != node && currNode.get_text() == newText) |
| { |
| alert('A folder with the given name already exists.'); |
| node.set_text(oldText); |
| node.startEdit(); |
| eventArgs.set_cancel(true); |
| return; |
| } |
| } |
| node.set_text(newText); |
| node.set_postBack(true); |
| } |
If I try to end edit mode with node.endEdit() before starting startEdit() again, it throws a null reference error.