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

Please explain how to parse filters from the URL

3 Answers 524 Views
Data Source
This is a migrated thread and some comments may be shown as answers.
Sean
Top achievements
Rank 1
Sean asked on 19 Jul 2012, 05:27 PM
I am implementing server side filtering and found the explanation of the filter data to expect from Kendo to be incomplete at best.  Depending on how many columns you sort on and in which order you do it, the filter parameters in the URL parameters vary considerably.  Noting that there's no direct way to translate them into maps and arrays, how exactly did you intend for us to parse them out?

If any of you have successfully implemented server side filtering, please respond with any info you could share about how you parsed out the filter parameters.

3 Answers, 1 is accepted

Sort by
0
Vesselin Obreshkov
Top achievements
Rank 2
answered on 27 Jul 2012, 05:37 PM
I'm assuming you're using ASP.NET / MVC...

First, take a look at this:

http://www.itq.nl/blogs/post/Kendo-UI-Grid-with-server-paging-filtering-and-sorting-(with-MVC3).aspx

Second, when using the MVC Extensions, there are couple of things to note:

When a grid makes a request, you need to have your action look like this:

public ActionResult GridData([DataSourceRequest]DataSourceRequest request)
{
  var filters = request.Filters;
  var sorts = request.Sorts;
 
  ...
}

Their filters all implement an IFilterDescriptor. There are 2 main types of filters: FiterDescriptor and CompositeFilterDescriptor. The FilterDescriptor describes a single filter (UserID~eq~1), a CompositeFilterDescriptor is used when composing filters with logical operators, it has a List<IFilterDescriptor> FilterDescriptors and a LogicalOperator properties. The default column filters that the grids send are CompositeFilterDescriptors even if they only contain a single filter and they come with a default LogicalOperator set to "and" but that's something you need to ignore if you don't have a second FilterDescriptor to join using the logical operator.

You can learn more by looking at the source of Kendo.Mvc.dll that comes with the MVC Extensions (or use JustDecompile to peek around). You want to see what they're doing with their IQueryable extensions.

We've implemented our own filtering in our Web API -based project and we convert the filters and sorts that come in from the grid to our own on-the-fly in our API Client class. I can try to help you out 
0
Sean
Top achievements
Rank 1
answered on 27 Jul 2012, 05:53 PM
Thanks for the response Vesselin.  I am using Java and there doesn't seem to be an extension for Java at the moment.  I ended up writing my own parsing routines.  I'd feel a lot better using something provided via an extension library since any changes they make to their filter scheme would be transparent to me, but for the time being my methods work.
0
Jerry
Top achievements
Rank 1
answered on 18 Nov 2012, 10:23 PM
Vesselin,

Can you show how you are converting the filters and sorts to your own?  

I have been trying to read up on LINQ Expressions and have been trying to manually build a link query to pass to a Entity Framework "GetFiltered" method, unfortunately it is taking me more time than I currently have on this task.

Any help would be greatly appreciated.

Thanks.
Tags
Data Source
Asked by
Sean
Top achievements
Rank 1
Answers by
Vesselin Obreshkov
Top achievements
Rank 2
Sean
Top achievements
Rank 1
Jerry
Top achievements
Rank 1
Share this question
or