-
-
Notifications
You must be signed in to change notification settings - Fork 72
Clearing filters in filter row of table not working #715
Description
I am entering filter queries with a separate input box. I see that I am able to successfully enter the query and it filters the table as expected. However, clearing the filter_query property on click of Clear Filter button does not remove text from the column filter.
In the below screenshot: Query is applied successfully.
After Clicking Clear Filters button - table is no longer filtered, but "eq Afghanistan" remains in column filter in table:
Here is the code:
app.layout = html.Div([
dcc.RadioItems(
id='filter-query-read-write',
options=[
{'label': 'Read filter_query', 'value': 'read'},
{'label': 'Write to filter_query', 'value': 'write'}
],
value='read'
),
html.Br(),
dcc.Input(id='filter-query-input', placeholder='Enter filter query'),
html.Div(id='filter-query-output'),
html.Hr(),
html.Button("Clear Filters", id="clear"),
dash_table.DataTable(
id='datatable-advanced-filtering',
columns=[
{'name': i, 'id': i, 'deletable': True} for i in df.columns
# omit the id column
if i != 'id'
],
data=df.to_dict('records'),
editable=True,
page_action='native',
page_size=10,
filter_action="native"
),
html.Hr(),
html.Div(id='datatable-query-structure', style={'whitespace': 'pre'})
])
@app.callback(
Output('datatable-advanced-filtering', 'filter_query'),
[Input('filter-query-input', 'value'), Input('clear', 'n_clicks')]
)
def write_query(query, clicks):
if clicks != None and clicks > 0:
return ''
else:
if query is None or query == '':
return ''
return query
I have seen the issue : #370. However, this issue pertains to specifically queries entered through an external input. (Clear filters button works fine for clearing filters applied by entering text in filter row of table)
Any suggestions on how to fix this issue will be greatly appreciated.