Quantcast
Channel: 🎛️ Dash - Plotly Community Forum
Viewing all articles
Browse latest Browse all 6271

DASH select/unselect checklist options

$
0
0

I am trying to create a button that selects/unselects all my checklist options in DASH. With the code that I have now, it is only selecting all options, the deselect option is not working.

dcc.Checklist(id='country_checklist',
                      options=[{'label': str(c), 'value': c} for c in sorted(df['Country'].unique())],
                      value=[],
                      labelStyle={'display': 'block'},
                      inputStyle={"margin-right": "5px"}
                      ),
        html.Button(className='button btn btn-primary btn-sm',
                    id='all-or-none1',
                    n_clicks=0,
                    children="Select/Unselect All")

@app.callback(Output('country_checklist', 'value'),
              [Input('all-or-none1', 'n_clicks')],
              [State('country_checklist', 'options')])

def select_all_none(all_selected, options):
    all_or_none1 = []
    all_or_none1 = [option['value'] for option in options if all_selected]
    return all_or_none1

1 post - 1 participant

Read full topic


Viewing all articles
Browse latest Browse all 6271

Trending Articles