dash-ag-grid
dash-ag-grid copied to clipboard
memory leak: Column API Function getColumnState() cannot be called as the grid has been destroyed
I have a checklist that updates the page with a different set of ag-grid depending on the selected option. I get the following error
Hello @dragonite00,
Could you please provide a working example of how you encounter this issue?
hey, thanks for the response!
The setup is basically, I have a (pseudocode) dbc.RadioItems(id="checklist", options={1:1, 2:2, 3:3})
@callback(
Output(display_id, "children"),
Input("checklist", "value")
)
def update_all_tables(value):
if value == 1:
return [ag.Grid(), ag.Grid(), ag.Grid()]
elif value == 2:
# different set
return [ag.Grid(), ag.Grid(), ag.Grid()],
....
if I click between the checklist values too quickly (actually it takes ~2s to return the ag grids so I'm not even clicking that fast), then I get the aforementioned error. along with a An object was provided as `children` instead of a component, string, or number (or list of those).
Hmm, interesting, have you tried using Patch with pre-existing grids?
In this style, I think you are encountering the issue because you are removing the grid before it can be fully spun up. We can take a look as see if there is something we can do to remove the events if the grid is removed before completely available.
Most api and columnApi functions will only occur after the grid is completely up, unless you are then trying to pass it data or columnDefs immediately...
You could also potentially use the new getApiAsync and getColumnApiAsync if you are trying to manipulate it.
Hmm, interesting, have you tried using Patch with pre-existing grids?
hmm, if you mean have a fixed set of grids, it's not possible because the checklist also controls the number of grids
We can take a look as see if there is something we can do to remove the events if the grid is removed before completely available.
this would be amazing, since this pattern seems most "intuitive" to me
Most api and columnApi functions will only occur after the grid is completely up, unless you are then trying to pass it data or columnDefs immediately...
Hm, I thought passing columnDefs in the return ag.Grid is the standard practice (at least from https://dash.plotly.com/dash-ag-grid/getting-started). Do you mean I could avoid this issue if I return the ag grid object first, and then add a callback to pass coldefs later?
edit: I just tried not passing coldefs on initialization, I still run into the exact same error
Can you please provide a working example of this?
I cannot dig into what is happening unless there is something to test with.
Are you also passing all the data and stuff to the grids too?
Hello @dragonite00,
Could you give this a test on the v31 of the grid to see if this issue persists?