Dash Ag Grid table columns not updating when id is equal

Hi all,

I have the issue that my dash Ag Grid table is not changing the column order, when the underlying data that I put in to rerun the function changes.

For example, I have a table

A B C

1 2 3

When running this the first time (with the correct order in columnDefs) in AgGrid with a specific id =”test”, it takes the order as intended.
Now, if I rerun the underlying data and obtain

A C B

1 2 3

and update the columnDefs to that, but the id is the same. It would should the data as
A B C

1 3 2

Note, the data is mapped to the columns correclty… it is just that the columns are ordered in the previous order.
The only way I found to solve this issue is by giving it a new id, however, I need this id and don’t want to rewrite everything that is already MATCHing this id.

I am thankful for any help on this.

Hello @xaver

What version of dag and dash are you using? Could you provide an example of your callbacks?

dash==3.0.4

dash_ag_grid==31.3.1

It is hidden in a helper function, but this is the return statement

return dag.AgGrid(

        columnDefs=[{"field": i, "columnSize": columnSize,}

                    for i in df.columns],

        rowData=df.to_dict("records"),

        className="ag-theme-balham",

        columnSize=columnSize,

        dashGridOptions={"domLayout": "autoHeight", "enableCellTextSelection": True, "suppressRowHoverHighlight": True},

        defaultColDef={"resizable": True, "sortable": sortable, "wrapHeaderText": True, "autoHeaderHeight": True},

        getRowStyle=getRowStyle,

        style=style

    )

that is put into this returned into this output.

@dash.callback(

Output("matrix-body", "children"),

What happens if you pass a resetColumnState=true as well?