Skip to content
This repository was archived by the owner on Jun 22, 2019. It is now read-only.

Cannot dynamically create tables #28

@mewais

Description

@mewais

Hello,

Tables are great, they work fine when used in a layout directly, something like this is OK:

app.layout = html.Div([
    html.Div(id='div1'),
    html.Div(id='div2'),
    html.Div(id='div3',children=[dt.DataTable(id='users table', rows=[{}], columns=['', 'col1', 'col2', 'col3', 'col4', 'col5'], filterable=True, sortable=True)])
])

But if you have a function create the table dynamically and assign it to the layout, tables do not even show up. This is needed for cases where you change the page content dynamically based on other inputs, for example If you decide whether to make a table or plot some figure based on a button, or if you want to have tables inside a tab body or so you'd have to do something like this:

app.layout = html.Div([
    html.Div(id='div1'),
    html.Div(id='div2'),
    html.Div(id='div3')
])

@app.callback(Output(div3', 'children'),
            [Input('dropdown1', 'value')])
def display_table(dropdown1_value):
    return dt.DataTable(id='users table', rows=[{}], columns=['', 'col1', 'col2', 'col3', 'col4', 'col5'], filterable=True, sortable=True)

This doesn't work, The table doesn't show up at all, and no error messages are printed.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions