Datatable - Apply conditional formatting to all columns

@threemonks Thanks for the example. The table’s props have changed a bit since February, especially during the 4.0 migration. The example code below uses dash==1.0.2 (dash-table==4.0.2) and while not an exact match for what you had above, should be equivalent.

import dash
from dash_table import DataTable, FormatTemplate

app = dash.Dash(__name__)

app.layout = DataTable(
        columns=[{"name": x, "id": x, 'type': 'numeric', 'format': FormatTemplate.money(0),} for x in ['a', 'b', 'c', 'd']],
        data=[
            {'a': '123', 'b': '234', 'c': 0, 'd': 456},
            {'a': '124', 'b': '235', 'c': 346, 'd': 457},
            {'a': '125', 'b': '236', 'c': 347, 'd': 458},
            {'a': '126', 'b': '237', 'c': 348, 'd': 459},
            {'a': '127', 'b': '238', 'c': 349, 'd': 450},
            {'a': '128', 'b': '239', 'c': 340, 'd': 451},
        ],
        filter_action="native",
        sort_action="native",
        page_action='native',
        style_cell={'whiteSpace': 'normal', 'textOverflow': 'ellipsis'},
        style_data_conditional=[ {
                'if': {'column_id': str(x), 'filter_query': '{{{0}}} > 125 && {{{0}}} < 458'.format(x)},
                'color': 'red',
            } for x in ['a', 'b', 'c', 'd']
        ],
    )
if __name__ == '__main__':
    app.run_server(debug=True)

Gives me:

Few things to note:

  • conditionals nested filter is now filter_query for consistency
  • columns were referenced as columnId, it’s now {columnId}
  • num(value) no longer exists and some common conversions are attempted automatically instead