ag-gridag-grid-angular

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:

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


Solution

  • 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);
            }
        });
    }