Sup! I’m new to dash. Faced with a problem:
I have a datatable with values which i am updating by inputs through callbacks. They are working.
data = pd.read_excel('Sample.xlsx')
app_layout=html.Div([
html.Div([dcc.Input(id='salary_budget_2020', type='number')]),
html.Div([html.Div(dash_table.DataTable(
id='dinamic_table',
columns=[{"name": i, "id": i} for i in datafortable.columns],
data=datafortable.to_dict("rows")))])
])
@app.callback(dash.dependencies.Output("dinamic_table", "data"),
[dash.dependencies.Input("salary_budget_2020", 'value')])
def update_table(salary_budget_2020):
datafortable = data.copy()
datafortable.at[8, '2020'] = datafortable.at[8, '2020'] - int(salary_budget2020 or 0)
return datafortable.to_dict('rows')
What i want to do is to set up cell conditional formatting based on the result of a comparison between original and updated value. I found ‘filter_query’ in docs but it’s not working with my updated-value variable.
What i need is to be able to compare original value in
datafortable.at[8, ‘2020’] and datafortable.at[8, ‘2020’] - int(salary_budget2020 or 0)
to be able to change background color if datafortable.at[8, ‘2020’] < datafortable.at[8, ‘2020’] - int(salary_budget2020 or 0) and etc. Something like:
{'if': {'column_id': '2020',"row_index": 8,
'filter_query': 'datafortable.at[8, '2020'] < datafortable.at[8, '2020'] - int(salary_budget2020 or 0)},'backgroundColor': '#3D9970','color': 'white'}
but what works) Thanks in advance!