how can we map the sorting,paging and Filtering array to web API .
kendo datasource is as below :
var data = new kendo.data.DataSource({
type: "json",
transport: {
read: function (e) {
$http({
method: 'POST',
url: $scope.kendoGridConfig.URL,
dataType: "json",
headers: { 'Content-Type': "application/json" },
data: e.data
}).
success(function (data, status, headers, config) {
e.success(data)
}).
error(function (data, status, headers, config) {
console.log(status);
});
},
Web API POST method
public HttpResponseMessage AllCountries([FromBody]KendoGridOptions KendoGridOptions)
{
var res = _countryMasterService.GetListAllKendo(KendoGridOptions);
return new HttpResponseMessage()
{
Content = new ObjectContent<KendoGridResults<CountryMasterView>>(res, new System.Net.Http.Formatting.JsonMediaTypeFormatter())
};
}
public class KendoGridOptions
{
//public KendoGridOptions()
//{
// this.sort = new List<GridSort>();
//}
public int Take { get; set; }
public int Skip { get; set; }
public int page { get; set; }
List<GridSort> sort { get; set; }
public int pageSize { get; set; }
}
public class GridFilter
{
public string Operator { get; set; }
public string Field { get; set; }
public string Value { get; set; }
}
public class GridFilters
{
public List<GridFilter> Filters { get; set; }
public string Logic { get; set; }
}
public class GridSort
{
public string field { get; set; }
public string dir { get; set; }
}