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

Adding a node client side from a webservice

5 Answers 99 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
Jacky Chau
Top achievements
Rank 1
Jacky Chau asked on 01 Aug 2008, 09:59 PM
I want to be add a node to a tree on the clientside.  However, I want the server to create the node since my business logic is on the server side.  Is it possible to have a webservice or pagemethod return a RadTreeNodeData and use that to create a clientside RadTreeNode?  Since you can already expand from an array of RadTreeNodeData via webservice, I am sure RadTree has a way to convert RadTreeNodeData to clientside RadTreeNode.  Is there function exposed?

5 Answers, 1 is accepted

Sort by
0
Yana
Telerik team
answered on 04 Aug 2008, 03:18 PM
Hello Jacky Chau,

Thank you for contacting us.

I suggest you use Load-On-Demand feature of RadTreeView via WebService. Please check our online example demonstrating this approach.

All the best,
Yana
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Jacky Chau
Top achievements
Rank 1
answered on 04 Aug 2008, 03:37 PM
Sorry if I didn't make my explanation clearer, but I already know how to load nodes via webservice when expanding a parent node.  What I want to do now is ADD a node on the clientside.  The parent node is already expanded and I want to add an additional node to the branch.  I want to know if there's a client side function that turns a RadTreeNodeData that's returned by a webservice into a client side RadTreeNode.  I am sure internally you guys have such a function to parse the array of RadTreeNodeData returned by the webservice when doing load on demand expanding. 

For example, I have a folder tree on a form.  There's a Add Folder button on the toolbar.  On the button click, I call a webservice to return a RadTreeNodeData.  Now I want to add a node to the tree based on the returned RadTreeNodeData json.  Is that possible?
0
Atanas Korchev
Telerik team
answered on 04 Aug 2008, 03:43 PM
Hello Jacky Chau,

We use the following code internally:

     var dynamicNode = new Telerik.Web.UI.RadTreeNode();
     dynamicNode._loadFromDictionary(nodeData);
     parentNode.get_childNodes().add(dynamicNode);

Keep in mind this is internal code which can change in the future. Use at your own risk.

Regards,
Albert
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Jacky Chau
Top achievements
Rank 1
answered on 04 Aug 2008, 03:47 PM
Thanks Albert!  That's exactly what I am looking for.  Do you mind sharing where nodeData is defined?  Is that just parsing the json returned by the webservice?  Is this code accessible to developers?
0
Atanas Korchev
Telerik team
answered on 04 Aug 2008, 03:51 PM
Hello Jacky Chau,

The "nodeData" variable is the object containing the node properties returned from the web service.

Kind regards,
Albert
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Tags
TreeView
Asked by
Jacky Chau
Top achievements
Rank 1
Answers by
Yana
Telerik team
Jacky Chau
Top achievements
Rank 1
Atanas Korchev
Telerik team
Share this question
or