Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to subscribe for a filter changed event in ag grid

Tags:

ag-grid

I have a problem in which i need to display the number of rows filtered in ag grid at run time.

How can I subscribe for a filter changed event in ag grid(javascript version )?

like image 622
Ashish Avatar asked Apr 23 '18 06:04

Ashish


People also ask

How do you detect change in Ag grid?

Angular Data Grid: Change Detection. The grid has built in change detection. When a value in the grid changes, either via the UI or via the grid API, the grid will check all cells to see which ones need updating and update exactly only those cells, so minimal changes are made to the DOM.

How do you get modified rows on Ag grid?

Ag grid api provides an inbuilt method "onCellValueChanged" that is triggered when we edit the grid. The line params. node. data['changed'] = true inserts an extra field to the row object whose cell underwent change.

How do you get the filter value on Ag grid?

To allow users to see the full filter value, tooltips can be enabled as shown below: const gridOptions = { columnDefs: [ { field: 'country', filter: 'agSetColumnFilter', filterParams: { showTooltips: true, } } ], // other grid options ... }

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) .


1 Answers

Ag grid has callbacks 'onFilterChanged' & 'onFilterModified'

var gridOptions = {
    columnDefs: columnDefs,
    rowData: null,
    enableFilter: true,
    onFilterChanged: function() {console.log('onFilterChanged');},
    onFilterModified: function() {console.log('onFilterModified');}
};

You can find more details here https://www.ag-grid.com/javascript-grid-filtering/

like image 167
user2220199 Avatar answered Sep 21 '22 15:09

user2220199