Step 1: Define a Cell Decorator Function
Cell decorators are JavaScript functions registered in thecellDecorators section of risksheet.json. Each function receives an info object and uses jQuery to toggle CSS classes on the cell element based on data values.
The info object provides:
| Property | Type | Description |
|---|---|---|
info.cell | HTMLElement | The DOM element of the cell being rendered |
info.item | object | The current row’s data object (access fields via info.item['fieldId']) |
info.value | any | The cell’s current value |
cellDecorators section:
boldCol— always applied (bold text)rpn1— applied when value is 1 to 150 (low risk)rpn2— applied when value is 151 to 350 (medium risk)rpn3— applied when value exceeds 350 (high risk)
You can define as many named decorators as needed in the
cellDecorators object. Each column can reference a different decorator via the cellDecorator property.Step 2: Define Matching CSS Styles
Create CSS class definitions in thestyles section of risksheet.json to define the visual appearance applied by your decorators. Style names must be valid CSS selectors prefixed with a dot:
| CSS Class | Risk Level | Background Color | Text Color | Description |
|---|---|---|---|---|
.boldCol | All | — | — | Bold font weight for emphasis |
.rpn1 | Low (1—150) | #eaf5e9 (light green) | #1d5f20 (dark green) | Acceptable risk |
.rpn2 | Medium (151—350) | #fff3d2 (light yellow) | #735602 (dark yellow) | Review recommended |
.rpn3 | High (>350) | #f8eae7 (light red) | #ab1c00 (dark red) | Mitigation required |
Step 3: Apply Decorators to Columns
Reference your decorator in the column configuration using thecellDecorator property. This activates the decorator for all cells in that column:
rpn decorator for consistent color coding.
Step 4: Configure a Row Header Renderer
Useheaders.rowHeader.renderer to apply conditional styling to the row header (the leftmost column showing row numbers). The renderer references a decorator name from the cellDecorators section:
info.item to read any property from the row’s work item. In this example, it reads the revised RPN value (rpnNew) to color the row header based on the post-mitigation risk level, providing at-a-glance risk assessment for each row.
| Row Header Rendering Flow | ||||
|---|---|---|---|---|
| headers. | cellDecorators. | styles. | ||
| rowHeader. | ---> | rowHeaderRpnNew | ---> | .rpn1 / .rpn2 |
| renderer | reads info.item | .rpn3 | ||
| Config names Function evaluates CSS classes | ||||
| the decorator row data values applied to cell |
Step 5: Register Custom Cell Renderers
For complete control over cell display (replacing the default rendering entirely, not just adding CSS classes), register custom cell renderer functions. Custom renderers differ from cell decorators:| Feature | Cell Decorators (cellDecorators) | Custom Cell Renderers (cellRenderers) |
|---|---|---|
| Purpose | Add/remove CSS classes | Replace cell HTML content |
| Registration | cellDecorators in risksheet.json | cellRenderers in risksheet.json |
| Column property | cellDecorator | cellRenderer |
| Parameters | info (cell, item, value) | grid, cell, item, value |
| Comparison mode | Disabled during comparison | Disabled during comparison |
The
cellRenderers registration mechanism is separate from cellDecorators. Verify the exact registration pattern for your Risksheet version, as the API may differ between releases.Step 6: Style Column Group Headers
Use styles with.firstRow and .lastRow selectors to differentiate column group header appearance. This is useful when organizing columns into header groups:
Complete Configuration Example
A fullrisksheet.json snippet combining cell decorators, styles, row header renderer, and column configuration:
Verification
You should now see:- RPN cells colored green, yellow, or red based on their calculated values
- Bold text applied to all RPN cells via the
boldColclass - Row headers colored according to the revised RPN value for at-a-glance risk assessment
- Column group headers with differentiated styling for first and last rows (if configured)
- No JavaScript errors in the browser developer console (
F12)
rpn1, boldCol) are present on the cell’s DOM element.
See Also
- Apply Conditional Formatting — broader conditional formatting patterns beyond cell decorators
- Configure Cell Styles — CSS style definition reference
- Configure Row Header Styles — row header customization options
- Render Custom Data — data rendering patterns for columns
- Cell Decorators — reference documentation for cell decorators
- Conditional Formatting — conditional formatting reference
- Custom Renderer Templates — template reference for renderers
Sources
Sources
Source Code
CellPreviewFormatter.tsWorkItemBasedReview.javarisksheet.jsonRisksheetProjectProperties.javaAppConfig.ts