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

LoadOnDemand - Webservice -AddNode

0 Answers 51 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
stone
Top achievements
Rank 1
stone asked on 12 Jan 2009, 08:04 AM
Hi,
when I use treeview in LoadOnDemand with a Webservice mode,I want to add new node from client side.
1.I use the content menu control to show user a menu,when user clicked the "NewNode" item,it will go to step 2.
2.I use the window control to show a prompt,with it user can input the new node name.
3.After user finish the input and click ok button in the prompt,I want to add node in the treeview selected node.
So I wirte the javascript code below:

 function promptCallBackFn(arg) {
                 if (arg != null) {
                    var tree = $find("<%= RadTreeView1.ClientID %>");
                    if (tree.get_selectedNode() != null) {
                        var node = tree.get_selectedNode();

                        AddNode(tree.get_selectedNode(), arg);
                    }
                }               
            }
              function AddNode(node, foldername) {

                var treeView = $find("<%= RadTreeView1.ClientID %>");
                treeView.trackChanges();
                var childNode = new Telerik.Web.UI.RadTreeNode();
                childNode.set_text(foldername);
                childNode.set_imageUrl("Img/mailfolder.gif");
                childNode.set_expandMode("Telerik.Web.UI.TreeNodeExpandMode.WebService");
                node.get_nodes().add(childNode);
                treeView.commitChanges();
               }
But When I test this,Error Occured.after I expand the Selected node first, this run well.
So I think mayby I should expanded the selected node first in my code,but it still couse error.
My questions is how to add node when we use LoadOnDemand - Webservice mode in client side.
I need a callback function to make sure that the select Node is Expanded successful and how to do this.

No answers yet. Maybe you can help?

Tags
TreeView
Asked by
stone
Top achievements
Rank 1
Share this question
or