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

[Solved] Server Filtering using DataSourceRequest in MVC API

3 Answers 701 Views
Data Source
This is a migrated thread and some comments may be shown as answers.
Andrew
Top achievements
Rank 1
Andrew asked on 24 Dec 2014, 01:46 AM
Hi,

I am having problem with server filtering in my mvc api controller. The DataSourceRequest Filter is null when I look at the request variable but if I enable server paging I can see the pagesize is being set. The model returns ok but with no filtering.
I have checked in Fiddler the request header and the filter is there, see below.

GET /api/Event?callback=jQuery19100650028504896909_1419384451525&filter%5Blogic%5D=and&filter%5Bfilters%5D%5B0%5D%5Bfield%5D=StateID&filter%5Bfilters%5D%5B0%5D%5Boperator%5D=eq&filter%5Bfilters%5D%5B0%5D%5Bvalue%5D=7&_=1419384451528 HTTP/1.1


MVC API Controller Code
public DataSourceResult GetEvents([ModelBinder(typeof(WebApiDataSourceRequestModelBinder))]DataSourceRequest request)
{
    return db.carEvent.ToDataSourceResult(request); 
}

Cordova App Code
var dataSource = new kendo.data.DataSource({
            transport: {
                read: {
                    url: "http://localhost:57459/api/Event",
                    dataType: "jsonp"
                }
            },
            schema: {
                data: "Data",
                model: {
                    ID: "id",
                    fields: {
                        ID: { type: "number" },
                        Event: { type: "string" },
                        Location: { type: "string" },
                        Information: { type: "string" },
                        StateID: { type: "number" },
                        EventDate: { type: "date" }
                    }
                }
            },
            serverFiltering: true,
            filter: { field: "StateID", operator: "eq", value: StateValue }
        });

Thanks Andrew

3 Answers, 1 is accepted

Sort by
0
Petur Subev
Telerik team
answered on 25 Dec 2014, 11:45 AM
Hello Andrew,

Could you please check the following project which demonstrated WebAPI binding through JavaScript configuration.

https://github.com/telerik/ui-for-aspnet-mvc-examples/tree/master/grid/webapi-crud

I noticed you are missing the parameterMap function. Fine tune your case according to the example and if struggling please demonstrate your case with a small isolated example.

Kind Regards,
Petur Subev
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
0
Andrew
Top achievements
Rank 1
answered on 28 Dec 2014, 11:31 PM
Hi Petur,

Thanks for the reply.
I downloaded the example you provided into Visual Studio but there is no example of the ParameterMap Function in JavaScript, there is only a Razor Kendo Grid HTML helper .

Thanks
Andrew
0
Alexander Popov
Telerik team
answered on 30 Dec 2014, 02:42 PM
Hello Andrew,

Here is an example project which is not using the ASP.NET MVC wrappers. You can also examine the rest of the examples in the same repository.

Regards,
Alexander Popov
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
Tags
Data Source
Asked by
Andrew
Top achievements
Rank 1
Answers by
Petur Subev
Telerik team
Andrew
Top achievements
Rank 1
Alexander Popov
Telerik team
Share this question
or