Dash-ag-grid: Apply filter on load

Hi,

I am trying to figure out how I can apply a data filter in code by default.
Right now I have a button that does the behavior I want.

I thought maybe there is someway to access these events through gridOptions: onGridReady, onFirstDataRendered, such as below:

However I don’t know how to make this work with dash.
All the grid options are set in the python code and I don’t see any way to access these events.

The code would just need to call this javascript function automatically once the data is loaded:

function restoreFromHardCoded(gridApi) {
    var hardcodedFilter = {
        AmountType: {
            type: 'set',
            values: ['Expense'],
        },
    };
    gridApi.setFilterModel(hardcodedFilter);
}

Thank you

I found that the filterModel can be set here in the python code:

return dag.AgGrid(
        filterModel={'AmountType': {'type': 'set', 'values': ['Expense']}}
)

Thanks

2 Likes