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

Unable to start_edit() a node if it is the only child of parent.

2 Answers 57 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
Himanshu
Top achievements
Rank 1
Himanshu asked on 22 Apr 2011, 04:50 PM
Hi,
  I'm not able to start_edit() a new node at the 2nd Level client-side if the parent node does not have any child previously and this is the only child.

Below is the code I've written to add a new node.

                function AddNode(parentNode)
                {
                    var tree = parentNode.get_treeView();
                    tree.trackChanges();
                    var node = new Telerik.Web.UI.RadTreeNode();
                    node.set_text("New Node");
                    node.set_value("New Node");
                    parentNode.get_nodes().add(node);
                    node.select();
                    tree.add_nodeEdited(NodeAdded);
                    tree.commitChanges();
                    node.startEdit();
                }


at the node.startEdit() statement it throws an error as: "htmlfile: Can't move focus to the control because it is invisible, not enabled, or of a type that does not accept the focus."


Please note that the ExpandMode of the Nodes are "WebService"

-Himanshu

2 Answers, 1 is accepted

Sort by
0
Dimitar Terziev
Telerik team
answered on 27 Apr 2011, 03:27 PM
Hi Himanshu,

This kind of error usually occurs in IE when you try to focus an element which is not visible.

In order to overcome this issue try to expand the parent item before you call the startEdit method.

Please try the following implementation of the AddNode function:
function AddNode(parentNode) {
 
    var tree = parentNode.get_treeView();
    tree.trackChanges();
    var node = new Telerik.Web.UI.RadTreeNode();
    node.set_text("New Node");
    node.set_value("New Node");
    parentNode.get_nodes().add(node);
    parentNode.expand();
    node.select();
    tree.add_nodeEdited(NodeAdded);
    tree.commitChanges();
    setTimeout(function() { node.startEdit() }, 20);
 
}

Regards,
Dimitar Terziev
the Telerik team

Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.

0
Himanshu
Top achievements
Rank 1
answered on 27 Apr 2011, 04:18 PM
Hi Dimitar,
 Thanks so much, this resolves my problem.


-Himanshu.
Tags
TreeView
Asked by
Himanshu
Top achievements
Rank 1
Answers by
Dimitar Terziev
Telerik team
Himanshu
Top achievements
Rank 1
Share this question
or