Dash DataTable Dynamic Dropdown Options

I’m having trouble updating the dropdown options in a Dash Datatable based on a callback. Basically, I need each dropdown’s options to change based on the row, which is also dynamic. I keep getting a TypeError: ‘Output’ object is not subscriptable. Can anyone please help, thank you!


#in the app.layout
column_static_dropdown=[                 
                        {
                            'id': 'Frequency',
                            'dropdown':
                                {
                                    'condition': '{Variable ID} eq "GDPC1"',
                                    'dropdown': []
                                }

                        },

                    ],

#in the callbacks
@app.callback(
    Output('Frequency', 'options')
    [Input('table-dropdown', 'data')])
def frequency(rows):
    all_frequency_options = OrderedDict(
        [('Annual', 'a'), ('Semiannual', 'sa'), ('Quarterly', 'q'), ('Monthly', 'm'), ('Biweekly', 'bw'),
         ('Weekly', 'w'), ('Daily', 'd')])
    for row in rows:
        spec_frequency_options = {}
        for k, v in all_frequency_options.items():
            if k == fred.get_series_info(row['Variable ID'])['frequency']:
                spec_frequency_options[k] = v
                break
            else:
                spec_frequency_options[k] = v
        return [{'label': key, 'value': val} for key, val in spec_frequency_options.items()]

Missing a comma here. Should be Output('Frequency', 'options'),

1 Like

Thank you! Sorry that was a dumb error. For some reason, the options of the dropdown are still not changing with the callback. Is this because dropdowns within the table don’t respond to callbacks? (this code works with a dropdown outside of the table)

It seems that the callback doesn’t recognize the dropdowns in the table as part of the layout. Is there another solution to this?