Black Lives Matter. Please consider donating to Black Girls Code today.

Deleting without entering cell generates None/data_style_contitional handling None

Hi All,

I’m trying to use style_data_conditional to highlight blank cells in red to alert the user of my dash app in case they’ve missed data. I’ve tried to write the code to handle both empty string and None, since both can be generated through blank data. This can be summarized as follows:

  1. entering the cell, deleting the contents, then pressing return, gives an empty string.
  2. clicking once on the cell, pressing delete and then return, gives None

I’ve tried to use the following code below to handle both cases, but I can’t work out how to get style_data_conditional to take None - it instead takes the string “None”. Does anyone know how I can enter None for this?

See images below showing the table and df illustrating the None issue, and style_data_conditional treating None as a string, with the code snippet below.

                style_data_conditional=[
                    {
                        "if": {
                            'column_id':'Process', 
                            "filter_query": '{Process} eq ""'
                        },
                        "backgroundColor": "red",                                            
                    },
                    {
                         "if": {
                            'column_id':'Task', 
                            "filter_query": '{Task} eq ""'
                        },
                        "backgroundColor": "red",                                           
                    },
                    {
                        "if": {
                            'column_id':'Time', 
                            "filter_query": '{Time} eq ""'
                        },
                        "backgroundColor": "red",                                            
                    }, 
                    {
                        "if": {
                            'column_id':'Process', 
                            "filter_query": '{Process} eq None'
                        },
                        "backgroundColor": "red",                                            
                    },
                    {
                         "if": {
                            'column_id':'Task', 
                            "filter_query": '{Task} eq None'
                        },
                        "backgroundColor": "red",                                           
                    },
                    {
                        "if": {
                            'column_id':'Time', 
                            "filter_query": '{Time} eq None'
                        },
                        "backgroundColor": "red",                                            
                    },                                                                                                               
                ],
                #above = code for when bug fix occurs 

Selection_063

Hi, first of all thanks for provided a detailed example, it really helps understanding your issue. Recent versions of Dash have a new operator “is blank”, would this solve the issue?

yes this appears to work! thank you very much!