This is a migrated thread and some comments may be shown as answers.

Adding clear filter toolbar button

1 Answer 326 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Ryan
Top achievements
Rank 1
Ryan asked on 16 Feb 2020, 05:31 PM

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.

 

1 Answer, 1 is accepted

Sort by
0
Viktor Tachev
Telerik team
answered on 19 Feb 2020, 02:05 PM

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.
Tags
Grid
Asked by
Ryan
Top achievements
Rank 1
Answers by
Viktor Tachev
Telerik team
Share this question
or