This is a migrated thread and some comments may be shown as answers.

[Solved] Canceling OnClientNodeEditing event with return to edit mode

3 Answers 119 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
Svilen
Top achievements
Rank 1
Svilen asked on 14 May 2008, 01:42 PM
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.
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); 
}            
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.

3 Answers, 1 is accepted

Sort by
0
Simon
Telerik team
answered on 16 May 2008, 08:52 AM
Hello Svilen,

Thank you for pointing the issue out.

It seemed that it is a bug in RadTreeView which has already been logged in our bug-tracking system.

Your Telerik points have been updated accordingly.

All the best,
Simon
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
Svilen
Top achievements
Rank 1
answered on 16 May 2008, 09:23 AM
Hello Simon,
Thanks for the reply.

Is there a possible workaround until the issue is fixed? Or any possibility of a fix before the next release?
0
Simon
Telerik team
answered on 19 May 2008, 11:47 AM
Hi Svilen,

I cannot offer you a workaround at the moment because the Node Editing event cannot be canceled (which actually is the problem).

I will contact you here when we resolve the problem and a hotfix is available.

Kind regards,
Simon
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
Tags
TreeView
Asked by
Svilen
Top achievements
Rank 1
Answers by
Simon
Telerik team
Svilen
Top achievements
Rank 1
Share this question
or