Invalid argument `dropdown` passed into DataTable with ID

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([
            columns=[{'name': 'Field A', 'id': 'Field A'}],
            data=[{'Field A': ''}],
                columns=[{'name': 'Field B', 'id': 'Field B', 'presentation': 'dropdown'}],
                data=[{'Field B': 'Default Value'}],
                dropdown={'Field B': {'options': [{'label': 'Default Value', 'value': 'Default Value'}]}},
            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'}]}}
        return {'Field B': {'options': [{'label': i, 'value': i} for i in range(3)]}},

if __name__ == '__main__':

Hi @itamargo,

It looks like you have a trailing comma after your second return statement in the callback:

return {'Field B': {'options': [{'label': i, 'value': i} for i in range(3)]}},

When you trail a comma after an object, Python wraps that object in a tuple

Ex: Running this in the Python Terminal…

> myList = [1,2,3]
> myList,
# output
# ([1, 2, 3],)

When I remove the comma, Python will then complain about the label and value params not being set to strings. Right now they are integers. Wrapping the i's in str() will do the trick.

With both these changes, this is what the line above looks like in correct form:

return {'Field B': {'options': [{'label': str(i), 'value': str(i)} for i in range(3)]}}


Hope that helped and happy coding :+1: