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

GRID: Databind to WEB API

1 Answer 78 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Josh
Top achievements
Rank 1
Josh asked on 15 Aug 2013, 09:31 PM
I can databind the grid to using DataSourceResult and HTTPGET no problems, the additional paramets are sent using querystring and readable through my WEB API controller.

My questions is can you/anyone provide an example of using HTTPOST and sending complex types as parameters?

How do you get around setting [FromBody] on the complex type yet still use the example below for HTTP model binder:



public DataSourceResult Method([ModelBinder(typeof(Imagine.Mvc.ModelBinders.KendoDataSourceRequestModelBinder))] DataSourceRequest request, 
            ComplexType object)
        {
            
        }

1 Answer, 1 is accepted

Sort by
0
Nikolay Rusev
Telerik team
answered on 20 Aug 2013, 08:25 AM
Hello Josh,

When handling POST request with complext types you should implement custom media type formatter. The following articles explains in details(with examples how this can be achived).

Media Formatters
Implementing Custom Media Formatters in ASP.NET WebAPI
Using JSON.NET with ASP.NET Web API
ASP.NET Web API Series - Part 5: MediaTypeFormatter explained

I'm also attaching a sample demonstrating Grid read operations with POST requests. The custom media formatter is used to parse and populate the DataSoureRequest object. This is required for properly population of the filter expressions which are also kind of complex object. 

Regards,
Nikolay Rusev
Telerik
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Tags
Grid
Asked by
Josh
Top achievements
Rank 1
Answers by
Nikolay Rusev
Telerik team
Share this question
or