I would like to control the grid's sorting, filtering, and column states with an external store. Ideally I want to intercept the filterChanged and sortChanged events, emit them to the store, and let the store update the grid programmatically using the grid API.
readonly GRID_CONFIG: GridOptions = {
onSortChanged: (event: SortChangedEvent) => {
// Tell store that the sort changed
this.sortChanged.emit(this.grid.api.getSortModel());
},
onFilterChanged: (event: FilterChangedEvent) => {
// Tell store that the filter changed
this.filterChanged.emit(this.grid.api.getFilterModel());
},
onFilterModified: (event: FilterModifiedEvent) => {
// This isn't useful because it only relates to the floating filters pre-apply...
}
}
Unfortunately, once the onFilterChanged and onSortChanged events are called, the grid has already been updated, so the updates from the store are redundant.
The closest thing to what I want is isApplyServerSideTransaction
, as this callback allows cancelling the transaction.
isApplyServerSideTransaction: (params: IsApplyServerSideTransactionParams) => {
// Emit model changes to the store so that the store can update the grid
this.sortChanged.emit(this.grid.api.getSortModel());
this.filterChanged.emit(this.grid.api.getFilterModel());
// Do not update the grid (redundant)
return false;
}
However, this is only supported for Server Side Row Model Full mode. This callback is never fired in my case, since I am using partial mode.
Are there any other tricks for hooking into the model changes before they're applied, or is this just not supported?
Update: I'm specifically trying to intercept the UI-triggered changes to the sort/filter model. I know this can be achieved with custom filters (and maybe custom headers?) but I'd much rather leverage Ag-Grid's built-in UI than build a whole custom copy, just to intercept one event.