问题
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?
回答1:
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);
}
});
}
来源:https://stackoverflow.com/questions/54823776/is-there-a-high-level-ag-grid-event-to-listen-to-any-change-to-column-state