DataTable only updates once - how can i refresh after triggering new callbacks

Hi Everyone,

Apologies for not finding a similar answer to this, but I have a Datatable where I select options from two drop downs and hit the submit button to update a Datatable (I query a redshift cluster via Pandas). Interestingly enough, the table will update the first time I hit the submit button, but will not update when a press the button again. Can someone explain to me what I am doing wrong?

#Layout
app = dash.Dash(__name__)

app.layout = html.Div([

dcc.Dropdown(
    id='scenario_selection',
    options=[
        {'label': 'Scenario 1', 'value': 'Scenario 1'},
        {'label': 'Scenario 2', 'value': 'Scenario 2'},
        {'label': 'Scenario 3', 'value': 'Scenario 3'},

        ,
    ],
    value=''
),

dcc.Dropdown(
    id='time_period',
    options=[
        {'label': 'FY19', 'value': 'FY19'},
        {'label': 'FY18', 'value': 'FY18'},
        {'label': 'FY17', 'value': 'FY17'},
        {'label': 'FY16', 'value': 'FY16'},
        {'label': 'FY15', 'value': 'FY15'},

    ],
    value=''
),

html.Button('Submit', id = 'button'),

html.Div(id = 'table'),

])

@app.callback(
dash.dependencies.Output("table", "children"),
[dash.dependencies.Input('button', 'n_clicks'),
dash.dependencies.Input('scenario_selection', "value"),
dash.dependencies.Input('time_period', "value")]
)

def update_table(n_clicks, scenario_selection, time_period):

if n_clicks:
    df = download_data(str(scenario_selection), str(time_period)) #query redshift cluster, #returns Pandas dataframe
    return html.Div([
        dash_table.DataTable(
            id = 'table',
            columns=[{
                "name": i, "id": i,
                'deletable': True
            } for i in df.columns],
            data= df.to_dict("rows")
            )

        ])

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

As a follow up question, in this example, I return html.div data table.

After I do this the first time, should I just be passing columns and rows back?

Hm, this seems like it might be a bug. What version of dash-table are you on?

import dash_table
print(dash_table.__version__)

The latest is 4.0.0.

Hi. Thanks a lot for your response. I am using 4.0.0.

Thanks. This looks like a bug to me, but we haven’t tried to reproduce locally. I’ve made a GitHub issue about it here: https://github.com/plotly/dash-table/issues/493

any suggestion on how to resolve this in the interim? You mentioned you have seen a similar issue once before – do you recall how it was resolved?

Thank you!