Adding clear filter toolbar button

2 posts, 0 answers
  1. Ryan
    Ryan avatar
    91 posts
    Member since:
    Aug 2012

    Posted 16 Feb 2020 Link to this post

    Hi All,

    I want to add a clear filter button on my grid toolbar. How can I achieve this? 

    Is it possible to get each filter changes in array?

    Like for instance my I set my 1st filter to column status to show only Active  

    My 2nd filter is user type admin on user type column

    and my 3rd filter to First Name column is Ryan

     

    So if I click the button Clear filter, it will only clear my 3rd filter for First name

    and when I click the 2nd time, it will clear my filter for User type Admin

    and when I click again the 3rd status active will be cleared.

     

    Actually my main goal here is to put this array in to bread crumb. although I cant seem to make breadcrumb work in my grid toolbar. so button would suffice for now.

     

  2. Viktor Tachev
    Admin
    Viktor Tachev avatar
    2499 posts

    Posted 19 Feb 2020 Link to this post

    Hello Ryan,

     

    Thank you for describing the scenario. Based on that I should say that there is no built-in feature that will remove the filters one by one on each click.

    Implementing such behavior would require custom code and keeping track of the filters applied to the Grid. To get the current filters for the Grid get reference of its dataSource and call the filter() method for it. That will return a JSON with the applied filters. 

    For changing the Grid filter again the filter() method can be utilized and the new filter should be passed as argument. That logic can be included in the click event of a custom toolbar button.

     

    Give the approach a try and let me know how it works for you.

     

    Regards,
    Viktor Tachev
    Progress Telerik

    Get quickly onboarded and successful with Telerik UI for ASP.NET Core with the dedicated Virtual Classroom technical training, available to all active customers.
Back to Top