We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy.
Unfortunately, activation email could not send to your email. Please try again.

DataManager with WCF-RESTful Example

Thread ID:

Created:

Updated:

Platform:

Replies:

116212 Apr 24,2014 11:18 PM Apr 29,2014 01:07 PM JavaScript 2
loading
Tags: ejDataManager
Simla
Asked On April 24, 2014 11:18 PM

Can I have an example about how-to use DataManager consume WCF-RESTful with and without parameter?



Madhu Sudhanan P [Syncfusion]
Replied On April 28, 2014 08:57 AM

Hi Simla,

 

Currently we are working in your requirement and we will update you the response on April 29, 2014.

 

Please let us know if you have any queries.

 

Regards,

Madhu Sudhanan. P


Madhu Sudhanan P [Syncfusion]
Replied On April 29, 2014 01:07 PM

Hi Simla,

 

Thanks for using Syncfusion products.

 

Based on your request, we have created a simple Grid sample which is loaded with the data from the WCF RESTful service using DataManager and the same can be downloaded from the following location.

 

Sample Location: OrderService.zip

 

In the above sample, we have created two Grids and a WCF RESTful service with two method “GetDataWithParam” and “GetDataWithOutParam”.  Those methods are implemented from the interface IOrder.

 

The method GetDataWithOutParam will be invoked when the URI is as defined in the UriTemplate as follow.

 

[OperationContract]

[WebGet(UriTemplate = "Orders",ResponseFormat = WebMessageFormat.Json)] //Call the method without parameter

string GetDataWithOutParam();

 

The method GetDataWithParam will be invoked when a request is made without parameter.

 

[OperationContract]

[WebInvoke(Method = "POST", UriTemplate = "Orders", RequestFormat = WebMessageFormat.Json,

ResponseFormat = WebMessageFormat.Json, BodyStyle = WebMessageBodyStyle.WrappedRequest)] //Call the method with parameter

string GetDataWithParam(int take,int skip);

 

 

 

To request the web service without parameter using DataManager, please refer the following code snippet. In the below code snippet , request will be made to the web service using executeQuery method.

 

 

var data1 = ej.DataManager({ url: "/Order.svc/Orders" });

        var query = new ej.Query();

        var dm = data1.executeQuery(query); //Request the webservice

        dm.done(function (e) {

            $("#Grid").ejGrid({

                dataSource: e.result

            });

        });

 

 

To request the WCF service with parameter, please refer the following code snippet. we have used the ej.Query() to add parameters and configured the DataManager using the UrlAdaptor and hence POST request will be send to the WCF RESTful Service with parameter skip and take.

 

 

var data2 = ej.DataManager({ url: "/Order.svc/Orders" });

        data2.adaptor = new ej.UrlAdaptor();

        var query1 = new ej.Query().skip(5).take(30); //Adding parameter to be send to the webservice

        var dm1 = data2.executeQuery(query1) //Request the webservice

 

        dm1.done(function(e){

            $("#Grid1").ejGrid({

                dataSource: e.result

            });

        });

Now the request will made to the webservice with parameter value skip as 5 and take as 30.

 

 

For getting started with WCF OData service please refer the following link.

 

 http://msdn.microsoft.com/en-us/data/odata.aspx

 

Please let us know if you have any queries.

 

Regards,

Madhu Sudhanan. P


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.

;