Hi,
DataSourceRequest ‘Sorts’ parameter (‘Filters’ and ‘Groups’
too) are null in my MVC action. Other parameters (‘PageSize’, for example) bind
properly.
If I use MVC wrapper for Kendo Grid everything works
perfectly, but I need to connect grid’s data source with MVC action without
wrapper. Is it possible?
JS libraries bundle:
jquery.min.js
kendo.all.min.js
kendo.aspnetmvc.min.js
Grid example:
$('#cars').kendoGrid({
pageable: true,
sortable: true,
dataSource: new kendo.data.DataSource({
serverPaging: true,
serverSorting: true,
schema: { data: "Data", total: "Total" },
transport: {
read: {
url: '@Url.Action("GetCars")',
contentType: "application/json; charset=utf-8",
type: "POST"
},
parameterMap: function (options) {
return JSON.stringify({ request: options });
}
}
})
});
HTTP request:
{"request":{"sort":[{"field":"Name","dir":"desc"}]}}
MVC action:
[HttpPost]
public JsonResult GetCars([DataSourceRequest]DataSourceRequest request)
{
..............
}
Thanks!
DataSourceRequest ‘Sorts’ parameter (‘Filters’ and ‘Groups’
too) are null in my MVC action. Other parameters (‘PageSize’, for example) bind
properly.
If I use MVC wrapper for Kendo Grid everything works
perfectly, but I need to connect grid’s data source with MVC action without
wrapper. Is it possible?
JS libraries bundle:
jquery.min.js
kendo.all.min.js
kendo.aspnetmvc.min.js
Grid example:
$('#cars').kendoGrid({
pageable: true,
sortable: true,
dataSource: new kendo.data.DataSource({
serverPaging: true,
serverSorting: true,
schema: { data: "Data", total: "Total" },
transport: {
read: {
url: '@Url.Action("GetCars")',
contentType: "application/json; charset=utf-8",
type: "POST"
},
parameterMap: function (options) {
return JSON.stringify({ request: options });
}
}
})
});
HTTP request:
{"request":{"sort":[{"field":"Name","dir":"desc"}]}}
MVC action:
[HttpPost]
public JsonResult GetCars([DataSourceRequest]DataSourceRequest request)
{
..............
}
Thanks!