plotly / dash

Data Apps & Dashboards for Python. No JavaScript Required.
https://plotly.com/dash
MIT License
21.29k stars 2.05k forks source link

Filtering for numeric column breaks if filtering is case insensitive #1793

Open ammaar8 opened 3 years ago

ammaar8 commented 3 years ago

Filtering for numeric columns breaks if we set column filtering to be case insensitive. This can be checked on https://dash.plotly.com/datatable/interactivity. If the toggle is set to be case sensitive, it filters correctly but as soon as I change it to be insensitive it breaks. This prevents us from setting filter_options={'case': 'insensitive'} and hide the toggle button since the filter won't work correctly. I think case sensitivity should be ignored if the column type is numeric or we can just always filter it with case sensitivity?

Datatable Case Sensisitivity Breaks filtering demo

gpedro178 commented 2 years ago

Had the same problem, I wanted to set filter_options={'case': 'insensitive'} and hide the button but the numeric filtering was wrong, I solved this by setting the "filter_options" for each column instead of using the table-level "filter_options", for example:

columns = [{
       "name": "continent"
       , "id": "continent"
       , "type": "text
       , "filter_options": {"case": "insensitive"}
},
{
       "name": "lifeExp"
       , "id": "lifeExp"
       , "type": "numeric"
       , "filter_options": {"case": "sensitive"}
}
]

Docs Reference

I hid the button using CSS:

input.dash-filter--case {
    display: none; 
 }