Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a high-level Ag-Grid event to listen to any change to column state?

I use Ag-Grid together with Angular and I would like to listen to any event that modify column state.

As of now, I have to list all events:

  • (columnVisible)=onCol($event)
  • (columnMoved)=onCol($event)
  • etc.

Is there a generic or higher-level event I could rely on in order to listen to any change to column state?

like image 245
balteo Avatar asked Jan 26 '23 16:01

balteo


1 Answers

There's addGlobalListener, listed here.

There's an example: https://www.ag-grid.com/javascript-grid-column-definitions/#column-api-example

Here's the relevant code from the Angular version of the example:

onGridReady(params) {
    this.gridApi = params.api;
    this.gridColumnApi = params.columnApi;

    params.api.addGlobalListener(function(type, event) {
        if (type.indexOf("column") >= 0) {
            console.log("Got column event: ", event);
        }
    });
}
like image 158
thirtydot Avatar answered Feb 09 '23 00:02

thirtydot