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

How to Use Grid with WebAPI for Paging, Filtering and Sorting

2 Answers 352 Views
Grid
This is a migrated thread and some comments may be shown as answers.
R R KABEL
Top achievements
Rank 1
R R KABEL asked on 16 Jul 2015, 05:14 PM

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; }
    }

2 Answers, 1 is accepted

Sort by
0
Alexander Popov
Telerik team
answered on 20 Jul 2015, 11:20 AM
Hi,

I would suggest checking the examples here.

Regards,
Alexander Popov
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
0
Alexander Popov
Telerik team
answered on 20 Jul 2015, 11:26 AM
Hi,

I would suggest checking the examples here.

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
Grid
Asked by
R R KABEL
Top achievements
Rank 1
Answers by
Alexander Popov
Telerik team
Share this question
or