Formatting Dash DataTable with dropdown menu's with varying column names

I am looking to get a Dash DataTable with in its first row a dropdown menu per column (see image below), in which the user can change the data type per column. The column names vary per dataset that the user uploads, but the dropdown options are fixed ([‘object’, ‘float64’…‘datetime64[ns]’])
datatable

I know from Dropdowns Inside DataTable | Dash for Python Documentation | Plotly that i can use the ‘dropdown’ parameter for this, but in their example their column names (=climate, temperature and city) are fixed, while mine are variable. How do I set dropdown options for a column name, which is unknown beforehand? Again, the image above shows exactly how I want the table to look.

code:

dropdown options = [option 1, option 2, option 3]

dash_table.DataTable(
            featureTypeTable.to_dict('records'),
            columns = [{"name": i, "id": i, 'presentation': 'dropdown'} for i in featureTypeTable.columns],
            editable=True,
        )

Hi @Robin66014
Have you tried updating the dropdown_conditional prop in a callback? You can include the columns prop as an Input

Solved it;

dash_table.DataTable(
            featureTypeTable.to_dict('records'),
            columns = [{"name": i, "id": i, 'presentation': 'dropdown'} for i in featureTypeTable.columns],
            editable=True,
            dropdown={
                i: {'options': [{'label': j, 'value': j} for j in
                                       ['object', 'float64', 'int64', 'bool', 'category', 'datetime64[ns]']]} for i in
                featureTypeTable.columns},
        ),
1 Like

Yeah that may have been a solution too! There is no real condition to it, but a callback wouldn’t be a bad idea