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
                            'id': 'Frequency',
                                    'condition': '{Variable ID} eq "GDPC1"',
                                    'dropdown': []



#in the callbacks
    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
                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)

1 Like

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

1 Like

I am trying to do something similar. Did you ever figure this out? I want to update dropdown options based on a dataframe that is updated periodically.

I just stumbled upon this, the dropdowns are controlled by the DataTable’s dropdown value, not the options. Thus, the output in this instance would be:

Output('Frequency', 'dropdown')

Keep in mind, any changes you make to this needs to include all combinations and layers of your targeted dropdown elements.