How to reset filtersettings and set to a new one at the same time

Hi,

We are working with syncfusion grids in our application. Currently, we are initially filtering a grid using the filtersettings option(checkboxtype filter). However, we are trying to reset filtersettings and set to it's initial value everytime user clicks a button. We found a similar thread https://www.syncfusion.com/forums/139067/programically-clear-all-filters-set-a-new-one-at-the-same-time solving this problem. However, can you please help us to solve this problem for Angular Grid?

Thanks!


3 Replies

AR Aishwarya Rameshbabu Syncfusion Team August 12, 2024 02:22 PM UTC

Hi Sudipa,


Greetings from Syncfusion support


After reviewing the information you provided, we understand that you initially applied a filter in the Grid and, after performing certain actions, you want to clear the current filter and revert to your original filter settings programmatically when a button is clicked. Based on your request we have prepared the sample in Angular platform, and we suggest you use the below way to achieve your requirement.


In this following sample, we clear the filter using the clearFiltering method on the button click event and then reapply the initial filter values to the Grid's filterSettings. Please refer to the code example and sample below for further details.


App.component.ts

 

reset() { //reset button click

        //invoke the clearFiltering method to clear the filtering in the Grid

        this.grid.clearFiltering();

        setTimeout(function() {

        //here we setback the initial filter values to the Grid

            this.grid.filterSettings.columns = [{ field: 'Employees', matchCase: false, operator: 'startswith', predicate: 'and', value: 'Nancy' },

        { field: 'Designation', matchCase: false, operator: 'startswith', predicate: 'and', value: 'Designer' }];

        }.bind(this));

    }

 


Sample: https://stackblitz.com/edit/angular-b4uvjf-r7zt4m?file=src%2Fapp.component.ts,src%2Fapp.component.html


Regards,

Aishwarya R



SU Sudipa August 14, 2024 08:36 AM UTC

Thank you very much for the reply. It helped a lot.



DM Dineshnarasimman Muthu Syncfusion Team August 15, 2024 12:34 PM UTC

Hi Sudipa,


Thanks for the update. We are glad that the provided solution met your requirement.


Regards,

Dineshnarasimman M


Loader.
Up arrow icon