dash load up with an empty table

Viewed 298

I am making my first dash application. I am creating a layout which will contain a dash_table however at load up time the table will be empty as the table will populate once the user selects an option.

I have tried setting the dash table to {} & none but when I do this the page will not load. How can I have an empty table as part of my layout when loading the page?

1 Answers

You need to provide a dictionary of column names at least to create an empty datatable. You can leave the data attribute as empty, here is a minimally working example:

from dash import Dash, dash_table, html

app = Dash(__name__)

app.layout = html.Div([
    dash_table.DataTable(id="table_infos",
        columns=[
            {'id': "Intitulé", 'name': "Intitulé"},
            {'id': "Donnée", 'name': "Donnée"}
        ]
    )
])

if __name__ == '__main__':
    app.run_server(debug=True)
Related