Set Multi Filter Programmatically

8 posts, 2 answers
  1. Brian
    Brian avatar
    45 posts
    Member since:
    Aug 2013

    Posted 11 Dec 2017 Link to this post

    Hi,

    Is it possible to programmatically set a column's filter whose "multi" flag is set to true on grid load?

    The code I have here:

    1.$("#Grid").data("kendoGrid").dataSource.filter({
    2.    field: "Person",
    3.    operator: "eq",
    4.    value: "Brian"
    5.});

    ... doesn't seem to filter properly or show the checkbox for the selected filter.  It filters out everything and no checkboxes in the filter menu are selected.

    Thanks!

  2. Answer
    Stefan
    Admin
    Stefan avatar
    3039 posts

    Posted 13 Dec 2017 Link to this post

    Hello, Brian,

    I made an example using the provided approach to set a filter programmatically and the filter was applied as expected on my end to the "ProductName" column:

    http://dojo.telerik.com/oruXO

    In case I missed an important part of the scenario, please modify the Dojo and I will gladly assist further.

    Regards,
    Stefan
    Progress Telerik
    Try our brand new, jQuery-free Angular components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
  3. Brian
    Brian avatar
    45 posts
    Member since:
    Aug 2013

    Posted 13 Dec 2017 in reply to Stefan Link to this post

    Hi Stefan,

    This works -- however, I'm using the MVC controls with the associated HtmlHelpers.  Does your scenario work with the MVC grid as well?

    Thanks!

  4. Answer
    Stefan
    Admin
    Stefan avatar
    3039 posts

    Posted 14 Dec 2017 Link to this post

    Hello, Brian,

    The same approach can be used in the MVC Grid.

    I made an example and the result is the same.

    I attached the example for reference.

    Regards,
    Stefan
    Progress Telerik
    Try our brand new, jQuery-free Angular components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
  5. Brian
    Brian avatar
    45 posts
    Member since:
    Aug 2013

    Posted 14 Dec 2017 in reply to Stefan Link to this post

    Hi Stefan,

    That was perfect.  I see what I did wrong now.  I used the column header name instead of the field name to filter on.

    Problem solved.  Thanks so much!

  6. Shishir
    Shishir avatar
    2 posts
    Member since:
    Mar 2016

    Posted 05 Jun 2019 in reply to Stefan Link to this post

    This does not works if set the dataSource.filter with multiple filters like this.

    $("#grid").data("kendoGrid").dataSource.filter(
                {
                    "filters": [{
                        "field": "ShipCity",
                        "operator": "ne",
                        "value": "ShipCity 2"
                        },
                    {
                        "field": "ShipName",
                        "operator": "ne",
                        "value": "ShipName 2"
                    }],
                    "logic": "and"
                }
            );

     

    Is there a different way of setting multiple filters?

  7. Tsvetomir
    Admin
    Tsvetomir avatar
    796 posts

    Posted 07 Jun 2019 Link to this post

    Hi Shishir,

    I have investigated the provided code snippets and it appears that they are set-up as expected. However, the project that has been provided by my colleague in the post below uses an outdated version of the Kendo UI suite. Can you try using the same approach with the latest version and see if the issue is still present?

    For your convenience, I am attaching the modified project to my response. Give it a try and let me know how it works out for you.


    Kind regards,
    Tsvetomir
    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.
  8. Shishir
    Shishir avatar
    2 posts
    Member since:
    Mar 2016

    Posted 23 Jul 2019 in reply to Tsvetomir Link to this post

    All good.

    Thanks

Back to Top