Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

autoSizeAllColumns bug #99

Closed
AnnMarieW opened this issue Mar 18, 2023 · 3 comments · Fixed by #111
Closed

autoSizeAllColumns bug #99

AnnMarieW opened this issue Mar 18, 2023 · 3 comments · Fixed by #111

Comments

@AnnMarieW
Copy link
Collaborator

Error when updating autoSizeAllColumns prop in a callback:

image

Here is MRE

from dash import Dash, html, Input, Output
import dash_ag_grid as dag
import pandas as pd

df = pd.read_csv("https://raw.githubusercontent.com/plotly/datasets/master/gapminder2007.csv")

app = Dash(__name__)

grid = dag.AgGrid(
    id="size-grid",
    rowData=df.to_dict("records"),
    columnDefs=[{"field": i, "id": i} for i in df.columns],
    defaultColDef={"resizable": True},
    columnSize="sizeToFit",
)


app.layout = html.Div([
    html.Button("Auto Size", id="auto-size"),
    grid
])


@app.callback(
    Output("size-grid", "autoSizeAllColumns"),
    Input("auto-size", "n_clicks"),
   # prevent_initial_call=True
)
def change_size(_):
    return True


if __name__ == "__main__":
    app.run_server(debug=True)
@BSd3v
Copy link
Collaborator

BSd3v commented Mar 18, 2023

This isn’t a bug, the grid isn’t ready, that is why it can’t be triggered immediately.

This needs to be delayed until the grid is ready if provided.

@AnnMarieW
Copy link
Collaborator Author

True - if you un-comment the prevent_initial_call=True in the example, the error goes away. However, it's not always possible to prevent callbacks from firing in a multi-page apps. Can the this error be handled in the component? https://github.com/plotly/dash-ag-grid/blob/dev/src/lib/fragments/AgGrid.react.js#L844

@BSd3v
Copy link
Collaborator

BSd3v commented Mar 18, 2023

That’s what my previous secondary statement was about.

This should be true for all event triggers.

BSd3v added a commit to BSd3v/dash-ag-grid-real that referenced this issue Mar 24, 2023
- info from the grid (read-only) (plotly#109)
- added output for `test_filter`
- added check for action props to delay until the grid is ready (plotly#99)
- set the default `dashGridOptions` to `{}` (plotly#97)
@BSd3v BSd3v linked a pull request Mar 24, 2023 that will close this issue
BSd3v added a commit to BSd3v/dash-ag-grid-real that referenced this issue Mar 28, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants