Skip to main content

Configuration

cellDecorators Property

NameTypeDefaultDescription
cellDecoratorsobject{}Maps decorator names to JavaScript function strings. Each function receives an info parameter and toggles CSS classes on the cell element.

styles Property

NameTypeDefaultDescription
stylesobject{}Maps CSS class selectors to CSS property blocks. Classes defined here are applied by cell decorator functions via toggleClass.

Function Signature

function(info) {
  // info.value - the current cell value
  // info.cell  - the DOM element of the cell
  // info.item  - the current row's data object
}
ParameterTypeDescription
info.valueanyThe display value of the current cell
info.cellHTMLElementThe DOM element to apply CSS classes to using jQuery $(info.cell)
info.itemobjectThe full work item data for the current row, providing access to any column value via info.item['<binding>']
Cell decorator functions compare against enum IDs (e.g., 'yes'), not display values (e.g., 'Y'). Always use the enum ID from your Polarion custom field configuration. Using the display value is a common source of non-working decorators.

Applying CSS Classes

Use jQuery toggleClass to add or remove CSS classes based on conditions:
function(info) {
  var val = info.value;
  $(info.cell).toggleClass('className', condition);
}
The toggleClass method takes two parameters: the CSS class name and a boolean condition. When the condition is true, the class is added; when false, it is removed. You can chain multiple toggleClass calls to apply different classes based on different thresholds.
CSS styles defined in the styles object often require the !important directive to override the default Risksheet grid styling. Without !important, your custom background colors and text colors may not appear.

Linking Decorators to Columns

Cell decorators are linked to columns in two ways:

Automatic Matching by Column ID

When a decorator name in cellDecorators matches a column’s id (or binding), the decorator is automatically applied to that column. No additional configuration is needed:
{
  "columns": [
    {
      "id": "rpn",
      "header": "RPN",
      "type": "int",
      "formula": "commonRpn"
    }
  ],
  "cellDecorators": {
    "rpn": "function(info){ ... }"
  }
}

Explicit Assignment via cellRenderer

To apply a decorator to a column that does not share the decorator’s name, use the column’s cellRenderer property:
{
  "columns": [
    {
      "id": "rpnInitial",
      "binding": "customField_rpnInitial",
      "header": "Initial RPN",
      "cellRenderer": "rpn"
    }
  ],
  "cellDecorators": {
    "rpn": "function(info){ ... }"
  }
}
Column PropertyTypeDefaultDescription
cellRendererstringundefinedName of the cell decorator function to apply to this column. References a key in the cellDecorators object.

Built-In Decorator Patterns

RPN Color Coding

Applies risk-level CSS classes based on RPN value thresholds:
{
  "cellDecorators": {
    "rpn": "function(info){ var val = info.value; $(info.cell).toggleClass('boldCol', true ); $(info.cell).toggleClass('rpn1', val>0 && val <= 150 ); $(info.cell).toggleClass('rpn2', val > 150 && val <= 350); $(info.cell).toggleClass('rpn3', val > 350);}"
  }
}
CSS ClassConditionRisk LevelBackgroundText Color
boldColAlways appliedAllNoneBold weight (font-weight:600)
rpn1val > 0 && val <= 150Low risk#eaf5e9 (light green)#1d5f20 (dark green)
rpn2val > 150 && val <= 350Medium risk#fff3d2 (light yellow)#735602 (dark yellow)
rpn3val > 350High risk#f8eae7 (light red)#ab1c00 (dark red)
diagram

Row Header Decorator

Applies conditional styling to row headers based on the revised RPN value:
{
  "cellDecorators": {
    "rowHeaderRpnNew": "function(info){ var val = info.item['rpnNew']; $(info.cell).toggleClass('rpn1', val>0 && val <= 150 ); $(info.cell).toggleClass('rpn2', val>0 && val > 150 && val <= 350); $(info.cell).toggleClass('rpn3', val>0 && val > 350);}"
  },
  "headers": {
    "rowHeader": {
      "renderer": "rowHeaderRpnNew"
    }
  }
}
To use a cell decorator on row headers, set headers.rowHeader.renderer to the decorator name. The row header decorator accesses info.item['rpnNew'] instead of info.value because the row header cell does not have a direct binding to the RPN field.

Enum Value Color Coding

Apply a background color when an enum field has a specific value:
{
  "cellDecorators": {
    "yesNoColor": "function(info){ var val = info.value; $(info.cell).toggleClass('greenBg', val === 'yes'); $(info.cell).toggleClass('redBg', val === 'no'); }"
  },
  "styles": {
    ".greenBg": "{background-color: #e8f5e9 !important; color: #2e7d32 !important;}",
    ".redBg": "{background-color: #ffebee !important; color: #c62828 !important;}"
  }
}

Severity-Based Color Coding

Apply graduated colors based on numeric severity ratings:
{
  "cellDecorators": {
    "severityColor": "function(info){ var val = info.value; $(info.cell).toggleClass('highSev', val >= 8); $(info.cell).toggleClass('medSev', val >= 4 && val < 8); $(info.cell).toggleClass('lowSev', val > 0 && val < 4); }"
  },
  "styles": {
    ".highSev": "{background-color: #ffcdd2 !important; color: #b71c1c !important;}",
    ".medSev": "{background-color: #fff9c4 !important; color: #f57f17 !important;}",
    ".lowSev": "{background-color: #c8e6c9 !important; color: #1b5e20 !important;}"
  }
}

Advanced Patterns

Conditional Read-Only Fields

Use systemReadOnlyFields to make specific columns non-editable based on item data:
{
  "cellDecorators": {
    "lockApproved": "function(info){ if(info.item['approvalStatus'] === 'approved'){ info.item['systemReadOnlyFields'] = info.item['systemReadOnlyFields'] || []; info.item['systemReadOnlyFields'].push('severity','occurrence','detection'); } }"
  }
}
This pattern prevents editing of severity, occurrence, and detection columns when the item’s approval status is approved. The systemReadOnlyFields property accepts an array of column bindings that should be locked.
The systemReadOnlyFields pattern for conditional column editability is an advanced technique. Test thoroughly in your environment before deploying to production.

Row Height Limiting

Limit row height for columns with long text content using a CSS max-height class:
{
  "cellDecorators": {
    "limitHeight": "function(info){ $(info.cell).toggleClass('maxHeightCell', true); }"
  },
  "styles": {
    ".maxHeightCell": "{max-height: 80px; overflow: hidden;}"
  },
  "columns": [
    {
      "id": "description",
      "header": "Description",
      "cellRenderer": "limitHeight"
    }
  ]
}
This workaround applies a CSS class with max-height to cells, referenced via the cellRenderer column property. It is a styling workaround rather than a built-in row height property.

Header Group Styles

The styles object also supports styling for column group header rows using compound selectors:
{
  "styles": {
    ".firstRow .headSysReq": "{background-color:rgba(62, 175, 63, 0.12) !important; color:#2A792D !important;}",
    ".lastRow .headSysReq": "{background-color:#FFF !important; color:#2A792D !important;}",
    ".firstRow .headFinalRanking": "{background-color:rgba(62, 175, 63, 0.12) !important; color:#2A792D !important;}",
    ".lastRow .headFinalRanking": "{background-color:#FFF !important; color:#2A792D !important;}"
  }
}
Selector PatternDescription
.firstRow .<groupCss>Styles the first header row of a column group
.lastRow .<groupCss>Styles the last header row of a column group
The <groupCss> value corresponds to the headerGroupCss property on the column definition.

Style Property Reference

PropertyTypeDefaultDescription
Style key formatstringCSS selector prefixed with . (e.g., .rpn1, .boldCol)
Style value formatstringCSS property block as a string (e.g., { font-weight:600; })
Standard CSS properties supported in styles include:
  • background-color — Cell background color
  • color — Text color
  • font-weight — Text weight (e.g., 600 for bold)
  • max-height — Maximum cell height (with overflow: hidden)
  • border — Cell border styling

Comparison Mode Behavior

Cell decorators are not applied during comparison mode (baseline comparison view). In comparison mode, the grid uses its own highlighting system to show added, removed, and modified cells. Custom cell renderers are also disabled during comparison to prevent visual conflicts with the comparison indicators.

Export Behavior

Cell decorator styles (background colors, text colors) are preserved when exporting to Excel and PDF formats (version 24.2.2+). The export process reads CSS colors from the rendered grid cells and converts them to the corresponding Excel fill/font colors or PDF styling.

Complete Example

{
  "cellDecorators": {
    "rpn": "function(info){ var val = info.value; $(info.cell).toggleClass('boldCol', true); $(info.cell).toggleClass('rpn1', val>0 && val<=150); $(info.cell).toggleClass('rpn2', val>150 && val<=350); $(info.cell).toggleClass('rpn3', val>350); }",
    "rowHeaderRpnNew": "function(info){ var val = info.item['rpnNew']; $(info.cell).toggleClass('rpn1', val>0 && val<=150); $(info.cell).toggleClass('rpn2', val>0 && val>150 && val<=350); $(info.cell).toggleClass('rpn3', val>0 && val>350); }",
    "severityColor": "function(info){ var val = info.value; $(info.cell).toggleClass('highSev', val >= 8); $(info.cell).toggleClass('medSev', val >= 4 && val < 8); $(info.cell).toggleClass('lowSev', val > 0 && val < 4); }"
  },
  "styles": {
    ".boldCol": "{font-weight:600;}",
    ".rpn1": "{background-color: #eaf5e9 !important;color: #1d5f20 !important;}",
    ".rpn2": "{background-color: #fff3d2 !important;color: #735602 !important;}",
    ".rpn3": "{background-color: #f8eae7 !important;color: #ab1c00 !important;}",
    ".highSev": "{background-color: #ffcdd2 !important;color: #b71c1c !important;}",
    ".medSev": "{background-color: #fff9c4 !important;color: #f57f17 !important;}",
    ".lowSev": "{background-color: #c8e6c9 !important;color: #1b5e20 !important;}",
    ".firstRow .headSysReq": "{background-color:rgba(62, 175, 63, 0.12) !important; color:#2A792D !important;}",
    ".lastRow .headSysReq": "{background-color:#FFF !important; color:#2A792D !important;}"
  },
  "headers": {
    "rowHeader": { "renderer": "rowHeaderRpnNew" },
    "columnHeader": { "height": 32 },
    "columnGroupHeader": { "height": 32 }
  },
  "formulas": {
    "commonRpn": "function(info){ var value = info.item['occ']*info.item['det']*info.item['sev']; return value?value:null; }",
    "commonRpnNew": "function(info){ var value = info.item['occNew']*info.item['detNew']*info.item['sevNew']; return value?value:null; }"
  }
}
KB ArticlesSupport TicketsSource Code
  • AppConfig.ts
  • risksheet.json
  • AppConfigHelper.ts
  • ExportToExcel.ts
  • CellPreviewFormatter.ts