Hi, I am trying to code functionality in WCF API which would return grid data by specifications (serverGrouping, serverFiltering, serverSorting);
My MVC code works, and it looks like this:
where "KendoToSpecificationHelper" is written-on-my-own class that gets data from request and creates Specifications (see Specification pattern);
Now I would like to code tse same functionality in WCF REST Service, which receives requests from distributed interface; The code I've just started looks like:
It is very similar to MVC code, but... it is not working :/. My pure javascript Kendo Grid code below:
When GRID reads data, it sends to a "getOrders(options)" function an object "options" with all required data; WCF correctly translates JSON to DataSourceRequest, but there is a problem with translating Sort list elements. My sort elements contains "Member" and "Dir" fields - WCF ignores Dir field, and always sets direction of sorting to "Ascending".
Is there any way to omit DataSourceRequest type parameter in a REST method, and manually create on a REST side filterDescriptors, groupDescriptors and sortDescriptors from only that JSON that Kendo Control is sending in Request? How to do that properly?
My MVC code works, and it looks like this:
[AutoMapperConfigurationActionFilter(
typeof
(OrderDomainMvcProfile))]
[NHibernateSession]
public
virtual
ActionResult OrderGrid_Select([DataSourceRequest]DataSourceRequest request)
{
var filterSpecification = KendoToSpecificationHelper.Filter<OrderDomainEntities.Order>(request.Filters);
var sortSpecificationList = KendoToSpecificationHelper.OrderSort(request.Groups, request.Sorts);
var groupSpecification = KendoToSpecificationHelper.OrderGroup(request.Groups);
Now I would like to code tse same functionality in WCF REST Service, which receives requests from distributed interface; The code I've just started looks like:
public
OrderContract[] ListSpecifiedOrders([DataSourceRequest]DataSourceRequest request)
{
_ContextHelper.SetCurrentWebOperationContext();
if
(_ContextHelper.AssertContextIsNull())
return
null
;
try
{
var filterSpecification = KendoToSpecificationHelper.Filter<Order>(request.Filters);
var sortSpecificationList = KendoToSpecificationHelper.OrderSort(request.Groups, request.Sorts);
var groupSpecification = KendoToSpecificationHelper.OrderGroup(request.Groups);
01.
jQuery(ORDER_GRID_ID).kendoGrid({
02.
// below js code to render control....
03.
// ..............
04.
"dataSource"
: {
05.
"transport"
: {
06.
"read"
:
function
(options) {
07.
getOrders(options);
08.
},
09.
},
10.
"schema"
: {
11.
"groups"
: [{
12.
"field"
:
"number"
13.
}],
14.
"data"
:
"data"
,
15.
"total"
:
"total"
16.
},
17.
"pageSize"
: 10,
18.
"serverPaging"
:
true
,
19.
"serverSorting"
:
true
,
20.
"serverFiltering"
:
true
,
21.
//"serverGrouping": true,
22.
"serverAggregates"
:
true
,
23.
"error"
: listOrdersView.OrderGrid_Error
24.
}
25.
}
When GRID reads data, it sends to a "getOrders(options)" function an object "options" with all required data; WCF correctly translates JSON to DataSourceRequest, but there is a problem with translating Sort list elements. My sort elements contains "Member" and "Dir" fields - WCF ignores Dir field, and always sets direction of sorting to "Ascending".
Is there any way to omit DataSourceRequest type parameter in a REST method, and manually create on a REST side filterDescriptors, groupDescriptors and sortDescriptors from only that JSON that Kendo Control is sending in Request? How to do that properly?