Enable simple Boolean expressions and comparisons in DataTable style_data_conditional filter_query
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 24.4k
- Forks
- 2.3k
- Avg merge
- 2d 7h
- Merged PRs (30d)
- 13
Description
I am trying to highlight rows in a DataTable if a column is False. I can’t seem to get it to work. Here’s what I’ve tried. Several failed attempts are left as comments.
dash_table.DataTable(
...
style_data_conditional= {
"if": {
# "filter_query": "{my_boolean_column}",
"filter_query": "{my_boolean_column} = True",
# "filter_query": "{my_boolean_column} = true",
# "filter_query": "{my_boolean_column} = 'true'",
},
"backgroundColor": "#FF4136",
},
)
I thought I was doing something wrong, but I made a post on the community forums, and another experienced user was also not able to make this work. Ideally, the first and second filter_query in my snippet above should work as written.
I was able to find a janky workaround, by adding a new column to the DataFrame I'm using to generate the DataTable that has values of either 0 or 1, and comparing to those instead of True or False. But it's very unergonomic.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by locating the DataTable implementation for style_data_conditional and the filter_query expression handling, then find any tests covering conditional row styling or comparisons. Verify the behavior with boolean values, including both True and False comparisons, and confirm that the documented expressions highlight the intended rows.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- data-visualization
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100