I am trying to edit a data table column dropdown options by using input from another data table but I keep getting this error:
Invalid argument `dropdown` passed into DataTable with ID "table-2".
Expected an object.
Was supplied type `array`
I am passing a dictionary the is in the same structure as the one I use on initialization,
even when I am returning the same attribute that I am trying to update (table-2, dropdown) with State I get the same error.
all consist example that reproduces the error (type into ‘Field A’)
import dash
import dash_html_components as html
from dash.dependencies import Input, Output, State
import dash_table
def define_add_row_single_die_table():
return html.Div([
html.Div([dash_table.DataTable(
id='table-1',
columns=[{'name': 'Field A', 'id': 'Field A'}],
data=[{'Field A': ''}],
editable=True),
dash_table.DataTable(
id='table-2',
columns=[{'name': 'Field B', 'id': 'Field B', 'presentation': 'dropdown'}],
data=[{'Field B': 'Default Value'}],
dropdown={'Field B': {'options': [{'label': 'Default Value', 'value': 'Default Value'}]}},
editable=True)],
style={"display": "grid", "grid-template-columns": "50% 50%", "vertical-align": "bottom"})])
app = dash.Dash(__name__)
app.layout = define_add_row_single_die_table()
@app.callback(Output('table-2', 'dropdown'),
[Input('table-1', 'data')],
state=[State('table-2', 'dropdown')])
def on_diefile_source_select(table_1_data, table_2_dd):
if table_1_data[0]['Field A'] == '':
return {'Field B': {'options': [{'label': 'Default Value', 'value': 'Default Value'}]}}
else:
return {'Field B': {'options': [{'label': i, 'value': i} for i in range(3)]}},
if __name__ == '__main__':
app.run_server(debug=True)