Custom filter based on calculate field

1 posts, 0 answers
  1. Andrew
    Andrew avatar
    7 posts
    Member since:
    Jul 2015

    Posted 21 Aug 2015 Link to this post

    Ok my requirement is simple and I am just getting lost in the various partial examples and forum posts on how to do this. What is surprising is I would expect this to be so standard there would hundreds of examples out there but I cannot find one.

     

    I have a basic person model with properties to include a birthdate.  All of those properties are on a grid in a MVC 5 Razor view.  The grid is setup and works fine.  What I would like to do is keep the existing filter capability on the birthdate field but add four additional filters that signify age groupings, so one for under 11 years old, one for between 11 and 14, and one for between 14 and 18, and one for over 18.

     

    Then of course since this is not a field in the actual database, I would need to do "custom server binding" as all the partial examples somewhat show. I have played with the datasourcerequest object in the past and I have no need to implement a fill blown custom binding scenario. Is it possible to just intercept these four requests, pull them out of the IFilterDescriptors, apply them manually, and then pass the remaining request object to the ToDataSourceResult method?

    If so I have not seen this either. If someone could please guide me to the right area on this I would appreciate it. To sum up:

    1. How do you add custom filters to the grid menu on a column but keep the default ones there?

    2. Can you intercept these filters and pull them out of the filter descriptor collection?

    3. How would you identify these custom filters to pull them out?

Back to Top