RadControls for ASP.NET AJAX The OnClientNodeEditStart client-side event is called as the edit begins. This event can not be canceled.
You can use this event to set any properties of the input area of the edited node.
The event handler receives parameters:
The treeview instance that fired the event.
Event arguments with functions:
get_node() retrieves a reference to the node being edited.
get_domEvent() retrieves a DOM event object of the node edit.
The example below uses the OnClientNodeEditStart event to change the text displayed in the INPUT area.
We will achieve the following: when you edit a node like Drafts (2) you will not see the (2) in the INPUT area, but only the real text like below. We will use the OnClientNodeEdited event to restore the number (2) to the original text upon saving.
CopyASPX
<telerik:RadTreeView ID="RadTreeView1"
OnClientNodeEditStart="OnClientNodeEditStartHandler"
OnClientNodeEdited="OnClientNodeEditedHandler"
Skin="Office2007"
AllowNodeEditing="true"
runat="server">
...
</telerik:RadTreeView>
CopyJavaScript
<script type="text/javascript">
var nodeCountInfo = "";
function OnClientNodeEditStartHandler(sender, eventArgs) {
var node = eventArgs.get_node();
var textInput = node.get_inputElement();
textInput.width = "150";
var regExpCount = /\(\d+\)/;
var matches = regExpCount.exec(node.get_text());
if (matches) {
nodeCountInfo = matches[0];
textInput.value = node.get_text().replace(nodeCountInfo, "");
}
}
function OnClientNodeEditedHandler(sender, eventArgs) {
var node = eventArgs.get_node();
sender.trackChanges();
node.set_text(node.get_text() + nodeCountInfo);
sender.commitChanges();
nodeCountInfo = "";
}
</script>
Note |
|---|
This event is available in all versions after Q3 SP2 2008 release. |
See Also