This is a migrated thread and some comments may be shown as answers.
Binding MVC Grid to WCF REST
3 Answers 55 Views
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Insomniac82
Top achievements
Rank 1
Insomniac82 asked on 05 Jan 2012, 07:40 PM
We are beginning to look at WCF4 REST Services and MVC3.  We are currently using SOAP and Telerik controls for WebForms.  
I am trying to use Telerik's MVC grid but I am having trouble figuring out how to intergrate it with REST service.  I am using Razor.

I am using your WebService Binding example as my start http://demos.telerik.com/aspnet-mvc/razor/grid/webservice?theme=vista
But it uses a SOAP service and I am having a couple of problems trying to plug in a REST service.
1) A complex type cannot be passed as REST parameter because QueryStringConverter cannot handle it.
2) I am not sure how to return a GridModel from REST.  I've tried returning GridModel and returning

context.CreateXmlResponse(gridModel).  Neither works (Error 324 (net::ERR_EMPTY_RESPONSE)).  (I've just started experimenting with REST and so far have only returned collections from Entity Framework so there may be something simple I don't know yet.)

Do you have any suggestions?

So far, my best idea is to take over paging myself and then utilize two REST calls: one to get the integer total count and a another to return a collection of dataobjects representing the page of grid rows.  Then, on the client, I can create the GridModel or do whatever I need to do to bind to the grid.

 

 

3 Answers, 1 is accepted

Sort by
0
Daniel
Telerik team
answered on 06 Jan 2012, 04:54 PM
Hi Glen,

WCF REST services are not supported by the MVC Grid. I can suggest using Ajax Binding instead or an action method which calls the REST service and returns a GridModel.
 

Greetings,
Daniel
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the Telerik Extensions for ASP.MET MVC, subscribe to their blog feed now
0
Insomniac82
Top achievements
Rank 1
answered on 06 Jan 2012, 04:55 PM
I got something working.

Use ajax binding.
In the ajax method
    call WCF rest service that returns a List<MyDataContract>, ResponseFormat = JSON
    use DataContractJsonSerializer to convert the JSON back to a list of DataContracts
    create a new GridModel using the list of DataContracts and return it in the view
in the view use a Grid<MyDataContract> that calls the ajax method

0
Mark de Torres
Top achievements
Rank 1
answered on 09 Oct 2012, 12:25 AM
Hi Guys,

I am new with the MVC framework..Could you please attached the solution please. I am trying to run the sample but i am keep getting the following error:

The resource cannot be found
Tags
Grid
Asked by
Insomniac82
Top achievements
Rank 1
Answers by
Daniel
Telerik team
Insomniac82
Top achievements
Rank 1
Mark de Torres
Top achievements
Rank 1
Share this question
or