@dashapp.callback(
Output(component_id='data-storage', component_property='data'),
Input(component_id='input', component_property='n_submit')
.
.
.
return json_data
@dashapp.callback(
Output('table', component_property='columns'),
Output('table', component_property='data'),
Output('table', component_property='style_cell_conditional'),
Input(component_id='data-storage', component_property='data'),
.
.
.
column_name = 'Target Column'
value = 'This value is a string'
table_columns = [{"name": i, "id": i} for i in df.columns]
table_data = df.to_dict("records")
conditional_formatting = [{
'if': {
'filter_query': f'{{{column_name}}} = {value}'
},
'backgroundColor': 'white',
'color' : 'black',
}
]
return table_columns, table_data, conditional_formatting<代码>G 210的预期效果一样
需要注意的是,当使用conditional_formatting部件时,所有回调都会被触发两次。发生这种情况后,data的行为就好像它已经被“病”值感染了一样,并且不允许新的数据。
示例:
步骤1.使用工作输入->在填充->数据存储后触发的所有回调按预期显示->数据
步骤2.使用工作输入->所有在填充->数据存储区后触发的回调,->数据按预期显示
步骤3.使用不工作的输入->所有回调被触发一旦->所有回调再次被触发显示与b输入相关的->数据)
步骤4.使用工作输入->所有回调被触发,一旦->所有回调再次触发,显示与b输入相关的->数据)
知道为什么会发生这种事吗?
任何反馈都是非常感谢的!
发布于 2022-12-03 10:02:23
conditional_formatting = [{
'if': {
'filter_query': f'{{{column_name}}} = "{value}"'
},
'backgroundColor': 'white',
'color' : 'black',
}
]问题在于失败的值有空的空间(例如旧金山)。增加引号解决了这个问题。
https://stackoverflow.com/questions/74659293
复制相似问题