Karthik G
Karthik G

Reputation: 1262

Kendo UI Grid, server filtering and sorting

I have an application with kendo UI Grid used with Angular. I enabled serverfiltering and serversorting.

My Backend has, WebAPI, custom Business Logic with entity framework. I use ViewModels/DTOs to bind data to my kendo grid, but when kendo grid is sorted or filtered, I need to filter on the EF by mapping the fields.

I tried searching online to see a similar concept, but most of them use oData which does not suit my requirement. I tried writing my own code to extend LINQ to sort or filter on the fields, but I run into issues with child/parent entities and a few more issues.

Can someone help me with this please?

Upvotes: 1

Views: 513

Answers (1)

Ripon
Ripon

Reputation: 141

I had a similar issue where I used SimplePaginate. Hope this might help you.

SimplePaginate Github

var filters = new Filters<Employee>(); 
filters.Add(!string.IsNullOrEmpty(searchText), x => x.LoginID.Contains(searchText));
filters.Add(!string.IsNullOrEmpty(jobTitle), x => x.JobTitle.Equals(jobTitle));

var sorts = new Sorts<Employee>();
sorts.Add(sortBy == 1, x => x.BusinessEntityID);
sorts.Add(sortBy == 2, x => x.LoginID, true); 
sorts.Add(sortBy == 3, x => x.JobTitle);

context.Employees.Paginate(currentPage, pageSize, sorts, filters);

NuGet Link

Upvotes: 1

Related Questions