Please explain how to parse filters from the URL

4 posts, 0 answers
  1. Sean
    Sean avatar
    7 posts
    Member since:
    Jan 2012

    Posted 19 Jul 2012 Link to this post

    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.
  2. Vesselin Obreshkov
    Vesselin Obreshkov avatar
    81 posts
    Member since:
    Jan 2010

    Posted 27 Jul 2012 Link to this post

    I'm assuming you're using ASP.NET / MVC...

    First, take a look at this:

    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 
  3. Sean
    Sean avatar
    7 posts
    Member since:
    Jan 2012

    Posted 27 Jul 2012 Link to this post

    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.
  4. Jerry
    Jerry avatar
    1 posts
    Member since:
    Oct 2011

    Posted 18 Nov 2012 Link to this post


    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.

Back to Top