Clearing `filtering_settings` does not clear the by-column filter fields
See original GitHub issueFrom community thread.
Clearing the filtering_settings
does not cause the by-column filter fields to be cleared. The table displays the right data but the fields themselves are showing the previous value.
Expected resolution:
- fixes the behavior
- adds at least one test demonstrating that resetting the
filtering_settings
prop causes the filter fields to be cleared in the UI
import pandas as pd
import numpy as np
from datetime import date
import dash
from dash.dependencies import Input, Output, State
import dash_html_components as html
from dash_table import DataTable
app = dash.Dash(__name__)
app.css.config.serve_locally = True
app.scripts.config.serve_locally = True
sColNames = ['a' + str(x) for x in range(date.today().year-6, date.today().year+1)]
df = pd.DataFrame(data = np.array([[1.5,0.0,-1.5]]*7).T, index=range(3), columns=sColNames) # Example dataframe
app.layout = html.Div(children=[
html.Button(id='clear', children='Clear filter'),
DataTable(
id='table',
columns=[{'name': i, 'id': i} for i in df.columns],
data=df.to_dict('rows'),
filtering=True
)
])
@app.callback(
Output('table', 'filtering_settings'),
[Input('clear', 'n_clicks')],
[State('table', 'filtering_settings')],
)
def clearFilter(n_clicks, state):
if n_clicks is None:
return '' if state is None else state
return ''
if __name__ == "__main__":
app.run_server(debug=True)
Issue Analytics
- State:
- Created 5 years ago
- Comments:7 (1 by maintainers)
Top Results From Across the Web
Clear or remove a filter - Microsoft Support
Remove filters from columns so you can view more or all of your data. ... button next to the column heading, and then...
Read more >Clearing Only Filtering Settings - Excel Ribbon Tips
On the Data tab of the ribbon, in the Sort & Filter group, there is a Clear tool. This tool clears all filtering...
Read more >How to Clear or Remove Filter in Excel - YouTube
In the previous tutorial you could see how to create a filter in Excel. Today, we'll have a look at how to clear...
Read more >Clear All Filter Criteria is not clearing all FilterConditions
I tested “clearing filter conditions” functionality in 14.2 and it is working as expected. AfterRowFilterChanged event is called for each column ...
Read more >DataTable clearFilter() not working properly - Stack Overflow
To clear all the inputs of the filters you can do it by javascript: <p:commandButton onclick="PF('vtWidget').clearFilters()" />.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
It looks like
filtering_settings
needs to be replace byfilter_guery
in the callback, like so :Just spent an hour reading all the threads on this matter and this is working for me.
No mention of
filtering_settings
in the official documentation, plus #169 opens a discussion about “the next version of thefiltering_settings
property. In particular : its name”.So I’m assuming
filter_query
is the new property name.Do correct me if I’m wrong !
Yes,
filter_query
. Please note the table API changed substantially with Dash 1.0 https://dash.plotly.com/dash-1-0-migration#dash_table and then as of last summer with Dash 2.0 this repo is no longer in use - dash-table is now part of the main repo https://github.com/plotly/dash