Multi select dropdown in datatable

Hi, may i know is there some ways to select more than 1 options for datatable’s dropdown. Like the dcc.Dropdown’s multi param? Thanks.

dcc.Dropdown

dcc.Dropdown(
    ['New York City', 'Montreal', 'San Francisco'],
    ['Montreal', 'San Francisco'],
    multi=True
)

dash datable

dash_table.DataTable(
        id='table-dropdown',
        data=df.to_dict('records'),
        columns=[
            {'id': 'climate', 'name': 'climate', 'presentation': 'dropdown'},
            {'id': 'temperature', 'name': 'temperature'},
            {'id': 'city', 'name': 'city', 'presentation': 'dropdown'},
        ],

        editable=True,
        dropdown={
            'climate': {
                'options': [
                    {'label': i, 'value': i}
                    for i in df['climate'].unique()
                ]
            },
            'city': {
                 'options': [
                    {'label': i, 'value': i}
                    for i in df['city'].unique()
                ]
            }
        }
    )

Could you please describe what the use case is?

I have ~10 options in a column. Want to let user select one/more of them. Thanks @stu

More details? Because, you know, we often use table components along with some relational models. And the use case you gave clearly deviates from 1NF.

1 Like
import dash_bootstrap_components as dbc
from dash import html

table_header = [
    html.Thead(html.Tr([html.Th("First Name"), html.Th("Last Name")]))
]

row1 = html.Tr([html.Td("Arthur"), html.Td("Dent")])
row2 = html.Tr([html.Td("Ford"), html.Td("Prefect")])
row3 = html.Tr([html.Td("Zaphod"), html.Td("Beeblebrox")])
row4 = html.Tr([html.Td("Trillian"), html.Td("Astra")])

table_body = [html.Tbody([row1, row2, row3, row4])]

table = dbc.Table(table_header + table_body, bordered=True)

And if you are exploring how to implement a complex table component, then this will be more meaningful for you currently.

I am storing and sometimes updating some products. I want to have a product label column, e.g. durable, kitchenware, dairy, etc. Other columns like product status (out of stock, refilling), name (milk, knife, etc). Would like to update the items in 1 page. Thanks stu.