仪表板中的有条件输入
是否可以在仪表板上进行有条件的输入?以下是我的代码。 的是,我希望仅在main_tab =='a''和main_tab =='b'时才成为输入
@app.callback(
Output('store-data', 'data'),
Input("inputid", "n_submit"),
Input("search-button","n_clicks"),
Input("tabs-main","value"),
Input("tabs","value"),
State("inputid", "value"),
prevent_initial_callback=True,
)
def store_data(n_submit,n_clicks,main_tab,tab,id_value):
if n_submit or n_clicks>0:
if main_tab=='A':
uniqueid = b64.encode(id_value)
locations_staging = query_staging.get_location(uniqueid,tab)
data = query_staging.get_data(locations_staging)
return data
elif main_tab=="B":
uniqueid = b64.encode(id_value)
locations_cu = query_cu.get_location(uniqueid)
data = query_cu.get_data(locations_cu)
return data
我想完成 ?
Is it possible to make Input conditional in dash? Below is my code. What I want to accomplish is, I want the tabs to be the input only if the main_tab == 'A', and if the main_tab=='B', I want the tab to be state (not input)
@app.callback(
Output('store-data', 'data'),
Input("inputid", "n_submit"),
Input("search-button","n_clicks"),
Input("tabs-main","value"),
Input("tabs","value"),
State("inputid", "value"),
prevent_initial_callback=True,
)
def store_data(n_submit,n_clicks,main_tab,tab,id_value):
if n_submit or n_clicks>0:
if main_tab=='A':
uniqueid = b64.encode(id_value)
locations_staging = query_staging.get_location(uniqueid,tab)
data = query_staging.get_data(locations_staging)
return data
elif main_tab=="B":
uniqueid = b64.encode(id_value)
locations_cu = query_cu.get_location(uniqueid)
data = query_cu.get_data(locations_cu)
return data
How to accomplish this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以在回调中创建条件。但是问题可能是当您想读取状态和输入的值以制定条件时,因为它们是模块上的类
dash.depentencies
。因此,您无法制定类似的条件:您可以使用帮助(输入)来阅读有关输入和状态的更多信息。
我认为您可以遵循当前的方法来制定调理。
You can create a condition inside a callback. But the problem might be when you want to read the values of State and Input to make a condition because they are classes on module
dash.dependencies
. Therefore, you cannot make a condition like:You can use help(Input) to read more about Input and State.
I think you can follow your current way to make conditioning.