anagha affinity anagha affinity - 6 months ago 86
AngularJS Question

Clear filter in ag-grid on tab changed

I have default filter and custom filter for

ag-grid
. I want to clear filter on tab change.

$scope.gridOptions = {
columnDefs: columnDefs,
rowData: null,
angularCompileRows: true,
enableSorting: true,
enableColResize: true,
enableFilter: true,
rowHeight: 35,
rowSelection: 'single',
onSelectionChanged: onSelectionChanged,
isExternalFilterPresent: isExternalFilterPresent,
doesExternalFilterPass: doesExternalFilterPass,
overlayLoadingTemplate: '<span class="ag-overlay-loading-center">Please wait while your rows are loading</span>',
overlayNoRowsTemplate: '<span style=" transform: translateY(-50%);opacity: 0.25;font-size: 3em;">No data available</span>'
};


I tried this but it's not working

$scope.gridOptions.api.resetFilters();
$scope.gridOptions.api.destroyFilter();


Please suggest any method to do reset all filters of
ag-grid
.

Answer

Try this:

$scope.gridOptions.api.setFilterModel(null);
$scope.gridOptions.api.onFilterChanged();