Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Ag grid resetting filters

I have tried to use ag grid for angular 2 and faced with the following behavior:

When I'm trying to type anything in column filter, grid is going to reload and reset filter as well. It happens not only if I type something for filtration but even if I'm trying to change type of the filter.

Anybody had similar issue?

like image 311
Neir0 Avatar asked Sep 06 '16 15:09

Neir0


People also ask

How do you reset the filter on Ag grid?

Example: Get / Set All Filter Models Set Custom Filter Model takes a custom hard-coded filter model and applies it to the grid. Reset Filters will clear all active filters. Destroy Filter destroys the filter for the Athlete column by calling gridApi. destroyFilter('athlete') .

How do you refresh AG grid with new data?

The easiest way to update data inside the grid is to replace the data you gave it with a fresh set of data. This is done by either updating the rowData bound property (if using a framework) or calling api. setRowData(newData) .

How do I know if my AG grid filter is applied?

Check this live example ag-grid: Built-In Filters - log the filters applied. Apply age and year filters and then click Log Filter button. age: {column: Column, filterPromise: Promise, scope: null, compiledElement: null, guiPromise: {…}}


1 Answers

I resolved this issue by adding property : newRowsAction: 'keep'

columnDefinition = {
    headerName: 'Athlete',
    field: 'athlete'
    // set the column to use text filter
    filter: 'text',
    // pass in additional parameters to the text filter
    filterParams: {apply: true, newRowsAction: 'keep'}
   }

From the ag-grid docs : https://www.ag-grid.com/javascript-grid-filtering/#gsc.tab=0

like image 125
MaNn Avatar answered Sep 20 '22 20:09

MaNn