Dropdown issues

I have created one dash app consisting of two filters. Each filter have dropdowns. After selecting, it returns the table. But problem is dropdowns is not able to accomodate None. What if one user want to filter data based on only filter. In that case, there is no option to ignore the one filter.

Hi @shrey24, if you want to ignore one of both filtering options, this basically means, all options of the ignored filter should be part of your output. So you will need the actual drop-down selection (value) and the drop-down options as variables in your callback and decide, what information to use to filter your table.

You could do something like this:

import dash
from dash import dcc, html, Input, Output, State
from dash.exceptions import PreventUpdate
import json

app = dash.Dash(__name__)

app.layout = html.Div(
    [
        dcc.Dropdown(
            id='drop_1',
            options=list('ABCD')
        ),
        dcc.Dropdown(
            id='drop_2',
            options=[*range(4)]
        ),
        html.Pre(id='out')
    ]
)


@app.callback(
    Output('out', 'children'),
    Input('drop_1', 'value'),
    Input('drop_2', 'value'),
    State('drop_1', 'options'),
    State('drop_2', 'options'),
    prevent_inital_call=True
)
def decide(select_1, select_2, opt_1, opt_2):
    if not select_1 and not select_2:
        raise PreventUpdate
    
    if not select_1:
        select_1 = opt_1
    if not select_2:
        select_2 = opt_2

    return json.dumps([select_1, select_2], indent=2)


if __name__ == '__main__':
    app.run(debug=True)

mred dropdown filter