Fill Empty Dataframe in AG Grid

Hello,

How to fill the empty dataframe in ag grid in the first time data load.

I am using [ ] in callback function but it is giving below error:
“TypeError: cannot unpack non-iterable NoneType object”

Thanks

Hi @Manpreet

Can you make a minimal example that reproduces the error?

For example, here is one way

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

df= pd.DataFrame()

app = Dash(__name__)

columnDefs = [
    { 'field': 'direction' },
    { 'field': 'strength' },
    { 'field': 'frequency'},
]

grid = dag.AgGrid(
    id="get-started-example-basic",
    rowData=df.to_dict("records"),
    columnDefs=columnDefs,
)

app.layout = html.Div([grid])

if __name__ == "__main__":
    app.run(debug=True)


You could also just set rowData to [] and it works as well.

I ran into a similar issue. However, I didn’t get the error you saw. I simply saw an empty grid with the “Loading” box. I couldn’t get that overlay to disappear even when I set the “rowData” attribute to “”.

It turned out I needed to specify the “columnDefs” in addition to the empty “rowData” list.:

def get_ag_grid():
    return dag.AgGrid(
        id="scan-grid",
        dashGridOptions={
            "pagination": True,
        },
        columnDefs=get_ag_grid_column_defs(),
        rowData=[],
        className="ag-theme-alpine-dark",
        columnSize="sizeToFit",
    )