I have an ag-grid table that has a column 'status' in which some values are 'active' and some are 'inactive'. I would like my table to only display rows that have an 'active' status by default. Using this question as a reference, I tried to set it like this using onFirstDataRendered:
const onFirstDataRendered = (params: FirstDataRenderedEvent) => {
const filter = params.api.getFilterInstance('status');
if (filter) {
filter.setModel({
type: 'equal',
filter: 'ACTIVE',
});
filter.onAnyFilterChanged();
}
};
but my code won't compile because it says I can't call onAnyFilterChanged because I "cannot invoke an object which is possibly undefined". Does anyone know how to fix this?