Changes in filter/sort/group format after KendoUI update to 2024. ASP MVC

1 Answer 24 Views
Filter Grid Sortable
Richard
Top achievements
Rank 1
Richard asked on 17 May 2024, 10:31 AM

We have been using an older version of your libraries from 2021 and decided to update it to the current one.

We have a grid and we have been using server-side filtering/sorting/etc... In the old version there used to be syntax like this: 

filter: RequestStatus~eq~1~and~PersonFullName~contains~'Steve'

 

We took this string, parsed, and processed the data. However, with the update, this is no longer the case. Now it looks like this:

And we are clueless on how to properly parse and or process this format on our back end.

 

This is the code that we use on the front end to query the back end.

    gridDataSource = new kendo.data.DataSource({
        serverFiltering: true,
        serverGrouping: true,
        serverSorting: true,
        serverPaging: true,
        serverAggregates:true,
        pageSize: 25,
            transport: {
                read: {
                    url: __config.baseUrlAbsolute + "Requests/Home/GetCurrentViewRequests",
                    dataType: "json",
                    data: function () {
                        return {
                            type: requestTypesList[requestType],
                            id: personId,
                        };
                    }
                }
            },
    });
    })

 

Our backend is .NET MVC and this is the method that we have used to process the request. But this no longer works.

 public string GetCurrentViewRequests([DataSourceRequest] DataSourceRequest request, int type, int id)
 {
       var filters = Request.Params.Get("filter");
       var groups = Request.Params.Get("group");
       var sorts = Request.Params.Get("sort");

       //Process
}

 

Would you be so kind as to point us in the right direction on how to properly parse and process the request?

1 Answer, 1 is accepted

Sort by
0
Neli
Telerik team
answered on 22 May 2024, 07:23 AM

Hi Richard,

The described format appears when ASP.NET MVC wrappers are used and the DataSource is set to AJAX type. You can try filtering in the demo link here and observe the network tab - https://demos.telerik.com/aspnet-mvc/grid/filter-row

Regarding how to handle the filtering on the server, when the DataSourceRequest is used you can take as an example the endpoint in the article linked below:

- https://docs.telerik.com/kendo-ui/knowledge-base/mutliselect-server-grouping-and-sorting

 public JsonResult GetProducts([DataSourceRequest]DataSourceRequest request)
    {
        var productss = ProductsAll().ToDataSourceResult(request);
        return Json(productss);
    }

As you will see in the example the ToDataSourceResult method is used. The ToDataSourceResult() method will page, sort, filter, and group the collection that is passed to it. If this collection is already paged, the method returns an empty result.

I hope this helps.

Regards,
Neli
Progress Telerik

Stay tuned by visiting our public roadmap and feedback portal pages! Or perhaps, if you are new to our Kendo family, check out our getting started resources
Tags
Filter Grid Sortable
Asked by
Richard
Top achievements
Rank 1
Answers by
Neli
Telerik team
Share this question
or