Display list of fields and values colored by value


#1

What is the best way to display a bunch of fields and values where the value is colored based on the value: (1-2 green, 2-3 yellow etc.)? Can UIViewDefinitionList do something like this?


#2

You should use the coloringValue formatter function for this.

Here is an example of a UIViewDefinitionList row where the value is colored red if less than zero, and black if greater than 0:

{
  "label": "Profit",
  "field": "profit",
  "format": {
    "funk": "coloringValue",
    "args": [
      [
        {
          "comparator": "<",
          "comparisonValue": 0,
          "conditionalValue": "#ff0000"
        },
        {
          "comparator": ">=",
          "comparisonValue": 0,
          "conditionalValue": "#000000"
        }
      ]
    ]
  }
},

See UIHelper.coloringValue for the documentation.