I have a datatable in Dash and I need to let user filter it with dropdowns (basic filtering doesn’t have multifilter and I have to get rid of typing). I created dropdowns, but I have no idea how to write my callback. I’m pasting code for dropdowns and datatable below and would be happy if anyone could help.
html.Div([
dcc.Dropdown(id='owner', options=[
{'label': i, 'value': i} for i in df.O_Name.unique()
], multi=True, placeholder='Select owner'),
html.Div(id='owners')],
style={'width': '15%', 'display': 'inline-block'}),
html.Div([
dcc.Dropdown(id='source', options=[
{'label': i, 'value': i} for i in df.PZ_Name_Source.unique()
], multi=True, placeholder='Select source'),
html.Div(id='sources')],
style={'width': '15%', 'display': 'inline-block'}),
html.Div([
dcc.Dropdown(id='destination', options=[
{'label': i, 'value': i} for i in df.PZ_Name_Destination.unique()
], multi=True, placeholder='Select destination'),
html.Div(id='destinations')],
style={'width': '15%', 'display': 'inline-block'}),
html.Div([
dcc.Dropdown(id='tariff', options=[
{'label': i, 'value': i} for i in df.TariffName.unique()
], multi=True, placeholder='Select tariff'),
html.Div(id='tariffs')],
style={'width': '15%', 'display': 'inline-block'}),
html.Div([
dcc.Dropdown(id='period', options=[
{'label': i, 'value': i} for i in df.Period.unique()
], multi=True, placeholder='Select period'),
html.Div(id='periods')],
style={'width': '15%', 'display': 'inline-block'}),
html.A(
html.Button('Export to CSV'),
id='download-link',
download="coeffmap.csv",
href="",
target="_blank"
),
html.A(
html.Button('Export to SQL'),
id='sql-link',
#download="coeffmap.csv",
href="",
target="_blank"
),
html.Div([dash_table.DataTable(
id='datatable',
columns=[
{"name": i, "id": i, "deletable": True} for i in df.columns
],
data=df.to_dict('rows'),
#export_format='csv',
#export_headers='names',
editable=True,
filter_action="native",
sort_action="native",
sort_mode="multi",
row_selectable="multi",
row_deletable=True,
selected_rows=[],
page_action="native",
page_current= 0,
page_size= 10000,
),
html.Div(id='table')]),
html.Div(id='datatable-interactivity-container')