Format NaN/Null values in Dash Grid AG

Hi,

I started using Grid AG in my Dash app. I would like to format (via styleConditions) cells that have NaN values.

How to do that?

In DataTable there was option is blank, but in does not work in Dash AG.

Thanks.

Hello @Hikari,

You could can use the cellClassRules, give it a class like empty and then format the style in your style sheet.

cellClassRules: {“empty”: “params.value ? false : true”}
.empty {
    color: red;
    border: 1pt solid red;
}
1 Like

Indeed, works fine. Thanks!

1 Like

Well, I found one problem.

Conditions are specified as follows:

'cellClass': "value_cell",
'cellClassRules': {
    'value_cell--large-posivite':'params.value == 0',
    'value_empty--empty':'params.value ? false : true',
}

and it looks like that dash does not distinguish between NaN and 0 values:
table

Any ideas how to solve it?

Do this instead.

'cellClass': "value_cell",
'cellClassRules': {
    'value_cell--large-posivite':'params.value == 0',
    'value_empty--empty':'params.value ? false : (params.value == 0 ? false : true)',
}

Perfect. Works like a charm :slight_smile:

1 Like