jimmybow / visdcc

Dash Core Components for Visualization.
MIT License
144 stars 18 forks source link

need to click the button multiple times to activate the sorting and selection function #6

Closed sylvoslee closed 5 years ago

sylvoslee commented 5 years ago

If I use the callback to display the table, I need to click the button multiple times to activate the sorting and selection function. Can you help solve this problem?

app.layout=html.Div([
    html.Button('output',id='output-btn'),
    html.Div('output')
])
@app.callback(
Output('output', 'children'),
[Input('output-btn', 'n_clicks')])
def update_wordcloud(n_clicks):
    if n_clicks is None:
        raise PreventUpdate
    return visdcc.DataTable(id = 'table2',
                            box_type = 'radio',
                            data = DF_SAMPLE,
                            scroll = {'y':200},
                            pagination = {'pageSize': 5},
                            style = {'width':'100%'})

https://community.plot.ly/t/share-visdcc-datatable-a-dash-component-for-antd-table/8227

jimmybow commented 5 years ago

your html.Div('output') has no id the correct code as following

app.config['suppress_callback_exceptions'] = True

app.layout=html.Div([
    html.Button('output',id='output-btn'),
    html.Div(id = 'output')
])

app.config['suppress_callback_exceptions']=True

@app.callback(
Output('output', 'children'),
[Input('output-btn', 'n_clicks')])
def update_wordcloud(n_clicks):
    if n_clicks is None:
        raise PreventUpdate
    return visdcc.DataTable(id = 'table2',
                            box_type = 'radio',
                            data = DF_SAMPLE,
                            scroll = {'y':200},
                            pagination = {'pageSize': 5},
                            style = {'width':'100%'})