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

StartNodeInEditNode in ascx(?)

1 Answer 41 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
Michel
Top achievements
Rank 1
Michel asked on 05 Dec 2011, 05:27 PM
Hey,

I can't edit a node after it is created (or copy).
My Treeview is in an ascx file...

For exemple :
protected void RadTreeView1_ContextMenuItemClick(object sender, RadTreeViewContextMenuEventArgs e)
{
    RadTreeNode clickedNode = e.Node;
     switch (e.MenuItem.Value)
    {
        case "Copy":
            RadTreeNode clonedNode = clickedNode.Clone();
            clonedNode.Text = string.Format("Copy of {0}", clickedNode.Text);
            clickedNode.InsertAfter(clonedNode);
            //set node's value so we can find it in startNodeInEditMode
            clonedNode.Value = clonedNode.GetFullPath("/");
            clonedNode.Selected = true;
            startNodeInEditMode(clonedNode.Text);
            break;
    }
}

and :
private void startNodeInEditMode(string nodeValue)
        {
            //find the node by its Value and edit it when page loads
            string js = "Sys.Application.add_load(editNode); function editNode(){ ";
            js += "var tree = $find(\"" + RadTreeView1.ClientID + "\"); ";
            js += "var node = tree.findNodeByValue('" + nodeValue + "');";
            js += "if (node) node.startEdit();";
            js += "Sys.Application.remove_load(editNode);};";
 
            RadScriptManager.RegisterClientScriptBlock(this, this.GetType(), "nodeEdit", js, true);
        }

(in debug nodeValue = "ADVANTECH/Automation Controllers")

I don't know what to try to edit the new node :-(
Enclosed : just after copy a node

1 Answer, 1 is accepted

Sort by
0
Kevin
Top achievements
Rank 2
answered on 06 Dec 2011, 02:19 PM
Hello Michel,

In you startNodeInEditMode js that your generating is using the findNodeByValue method , while you are passing to the method the text of the Node. You should be passing in the value, if that's what you're using to locate the node.

I hope that helps.
Tags
TreeView
Asked by
Michel
Top achievements
Rank 1
Answers by
Kevin
Top achievements
Rank 2
Share this question
or