Removing specific filters from Request.Filters

3 posts, 1 answers
  1. Denny
    Denny avatar
    4 posts
    Member since:
    Aug 2018

    Posted 20 Sep 2018 Link to this post

    We're attempting to do custom filtering on the server-side by passing additional data via the filters. However these custom filters do not correlate to any of the properties of the result set so we end up with an error:

    Invalid property or field - 'GroupNameId' for type: InventorySearchResult

    Unfortunately its not as simple as adding the GroupNameId to the result because GroupNameId is in a collection of Group Names, example:

    MyEntity {
     Id = 1,
     Name = "name",
     GroupNames = <Collection of Group Names that I want to further filter against>

    So what we do is query our data via IQueryable, extract the GroupNameGid filter from Request.Filters, then manually apply a filter for GroupNameGid to the expression, then we return the data via ToDataSourceResult(...). Unfortunately this results in the error mentioned above. I thought maybe I could remove the GroupNameGid filter from Request.Filters since I'm manually applying the filter and let ToDataSourceResult apply the rest of its magic. However this turned out to be rather complicated due to CompositeFilterDescriptor. So I'm curious to know if there is any way to easily remove a specific filter from request.Filters.


  2. Answer
    Tsvetina avatar
    2481 posts

    Posted 24 Sep 2018 Link to this post

    Hi Denny,

    I think it would be best to pass the additional values as a standalone parameter and not as a part of the filter expression. You can use  the Data method that specifies a JavaScript function, which will return the additional parameters.
    .Read(read => read.Action("Products_Read", "Grid").Data("additionalInfo"))

    function additionalInfo() {
        return {
            name: "test",
            id: 2

    Then, in the controller method, list the additional values as arguments:
    public ActionResult Products_Read([DataSourceRequest] DataSourceRequest request, string name, int id) {...}

    You can pass any number of values and access them as separate arguments of the controller action method. In this way, you will not need to modify the DataSourceRequest filters manually.

    Progress Telerik
    Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
  3. Denny
    Denny avatar
    4 posts
    Member since:
    Aug 2018

    Posted 24 Sep 2018 in reply to Tsvetina Link to this post

    Yes, the more I dig into this the more I agree, these should be handled separately.


Back to Top