无法在破折号仪表板页面中更新 2 个不同的表
Cannot update 2 different tables in a dash dashboard page
我有一个包含 table 的短划线页面。
从回调中,我可以根据日期选择器或下拉列表中的过滤器更新 table 中的信息。
@app.callback(
Output('table_web', 'data'),
[Input(component_id='datepickerrange', component_property='start_date'),
Input(component_id='datepickerrange', component_property='end_date'),
Input(component_id='my_button', component_property='n_clicks')],
[State(component_id='table_dropdown_web', component_property='value')]
)
当我想添加另一个代表其他内容的 table 时,我的问题出现了,我想用另一个回调过滤那个 table,它有自己的输入。
但我不知道如何为 2 个 table 声明 2 个回调,以便第一个回调处理第一个 table,第二个回调调用第二个 table.
我试过这样的事情:
@app.callback(
Output('table_teste', 'data_table1'),
[Input(component_id='datepickerrange', component_property='start_date'),
Input(component_id='datepickerrange', component_property='end_date'),
Input(component_id='my_button_2', component_property='n_clicks')],
)
def create_table_1(start_date, end_date, n):
# code
return data_table1
@app.callback(
Output('table_web_utm', 'data_table2'),
[Input('my_button', 'n_clicks')],
[State('my_txt_input', 'value')]
)
def create_table_2(n, value):
code
return data_table2
我想通了。
以防有人遇到同样的问题。
我应该在回调和函数的 return 中用“数据”命名输出。
@app.callback(
Output('table_teste', 'data'),
[Input(component_id='datepickerrange', component_property='start_date'),
Input(component_id='datepickerrange', component_property='end_date'),
Input(component_id='my_button_2', component_property='n_clicks')],
)
def create_table_1(start_date, end_date, n):
# code
return data
@app.callback(
Output('table_web_utm', 'data'),
[Input('my_button', 'n_clicks')],
[State('my_txt_input', 'value')]
)
def create_table_2(n, value):
code
return data
我有一个包含 table 的短划线页面。 从回调中,我可以根据日期选择器或下拉列表中的过滤器更新 table 中的信息。
@app.callback(
Output('table_web', 'data'),
[Input(component_id='datepickerrange', component_property='start_date'),
Input(component_id='datepickerrange', component_property='end_date'),
Input(component_id='my_button', component_property='n_clicks')],
[State(component_id='table_dropdown_web', component_property='value')]
)
当我想添加另一个代表其他内容的 table 时,我的问题出现了,我想用另一个回调过滤那个 table,它有自己的输入。
但我不知道如何为 2 个 table 声明 2 个回调,以便第一个回调处理第一个 table,第二个回调调用第二个 table.
我试过这样的事情:
@app.callback(
Output('table_teste', 'data_table1'),
[Input(component_id='datepickerrange', component_property='start_date'),
Input(component_id='datepickerrange', component_property='end_date'),
Input(component_id='my_button_2', component_property='n_clicks')],
)
def create_table_1(start_date, end_date, n):
# code
return data_table1
@app.callback(
Output('table_web_utm', 'data_table2'),
[Input('my_button', 'n_clicks')],
[State('my_txt_input', 'value')]
)
def create_table_2(n, value):
code
return data_table2
我想通了。 以防有人遇到同样的问题。
我应该在回调和函数的 return 中用“数据”命名输出。
@app.callback(
Output('table_teste', 'data'),
[Input(component_id='datepickerrange', component_property='start_date'),
Input(component_id='datepickerrange', component_property='end_date'),
Input(component_id='my_button_2', component_property='n_clicks')],
)
def create_table_1(start_date, end_date, n):
# code
return data
@app.callback(
Output('table_web_utm', 'data'),
[Input('my_button', 'n_clicks')],
[State('my_txt_input', 'value')]
)
def create_table_2(n, value):
code
return data