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

Send Nodes to WebService...

3 Answers 66 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
Christian
Top achievements
Rank 1
Christian asked on 05 Aug 2008, 10:44 AM
Hi!

How do i send node to a webservice method?

I would like to send node to a webservice method for further processing. I use the NodeDropping event like this:

function

ServiceTree_NodeDropping(sender, eventArgs)
{
   
var destNode = eventArgs.get_destNode();
   
if(!destNode.get_allowDrop())
    {
        eventArgs.set_cancel(
true);
       
return;
    }
   
    // Call to webservice method
    MyService.MyMethod(destNode, eventArgs.get_sourceNodes());
}

What should my webservice mehod signature look like in this example, where i would like to send both a single Node and an array/list of node?

Best Regards,
Christian

3 Answers, 1 is accepted

Sort by
0
Accepted
Atanas Korchev
Telerik team
answered on 05 Aug 2008, 10:49 AM
Hello Christian,

You can create a new object and map treenode properties to it:

var param = {};
param.Text = node.get_text();
param.Value = node.get_value();

WebService.WebMethod(param);

Then you can use an IDictionary for the web service method.

public void WebMethod(IDictionary<string, object> param)
{
     string text = (string)param["Text"];
}

The same goes with the array - pass an array of objects to the web service method. Then use IEnumerable as the type of the web service method argument.

Best wishes,
Albert
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Christian
Top achievements
Rank 1
answered on 05 Aug 2008, 11:09 AM
Thanks!
0
Jacky Chau
Top achievements
Rank 1
answered on 05 Aug 2008, 03:46 PM
Can you provide the code that is used to pass a RadTreeNodeData to the webservice when using load-on-demand for expanding?  The webservice signature is something like:

Public Shared Function GetTreeSubItems(ByVal node As RadTreeNodeData, ByVal context As ObjectAs RadTreeNodeData() 

How do I pass in a RadTreeNodeData from the clientside to the webservice?  Is there a private internal function that turns a clientside RadTreeNode to clientside RadTreeNodeData?
Tags
TreeView
Asked by
Christian
Top achievements
Rank 1
Answers by
Atanas Korchev
Telerik team
Christian
Top achievements
Rank 1
Jacky Chau
Top achievements
Rank 1
Share this question
or