Overview
Cell decorators are defined in thecellDecorators configuration section and are referenced by column configuration or header renderer properties. Each decorator function receives an info object containing the cell element, cell value, and row item data, allowing you to inspect values and apply CSS classes conditionally.
Function Structure
Cell decorators are JavaScript function strings stored in the configuration. They receive aninfo parameter with the following properties:
| Property | Type | Description |
|---|---|---|
info.cell | DOM Element | The HTML cell element being decorated |
info.value | any | The cell’s display value (used for value-based decorators) |
info.item | object | The entire row’s data object (used for row-based styling) |
info.column | object | The column configuration object |
Configuration Properties
| Property | Type | Default | Description |
|---|---|---|---|
cellDecorators | object | {} | Collection of named decorator functions |
cellDecorators.<name> | string | — | JavaScript function that applies CSS classes to cells |
column.cellRenderer | string | — | References a decorator function to apply to this column |
headers.rowHeader.renderer | string | — | References a decorator function for row header styling |
Common Patterns
Value-Based Decorators
Decorators that style cells based on their own value:info.value and applies different CSS classes based on ranges. Each class is defined in the styles section.
Row-Based Decorators
Decorators that style cells based on other row values:info.item (the row’s data object) and applies styling based on that value. Useful for row header styling where you want to style the header based on column data.
Enum-Based Decorators
When decorating cells based on enum values, use the enum ID (not the display value):CSS Class Application
Cell decorators apply CSS classes using jQuery’stoggleClass() method (or vanilla DOM methods). The toggleClass() function signature:
| Parameter | Type | Description |
|---|---|---|
className | string | The CSS class name to toggle |
condition | boolean | If true, the class is added; if false, it’s removed |
CSS Class Priority
When multiple decorators apply classes to the same cell, or when decorator classes conflict with existing styles, use the!important flag in your CSS definitions to ensure proper precedence:
Column Binding Configuration
To apply a cell decorator to a column, reference it in the column’scellRenderer property:
cellRenderer property must match a decorator name defined in cellDecorators.
Row Header Styling
To apply decorators to the row header column, configure theheaders.rowHeader.renderer property:
rowHeaderRpnNew decorator function, which receives the row header cell as info.cell and can access row data via info.item.
Complete Example
Here’s a complete configuration example combining decorators and styles for FMEA risk visualization:- The
rpndecorator colors RPN cells based on thresholds - The
rowHeaderRpnNewdecorator colors row headers based on therpnNewfield value - Both decorators reference CSS classes defined in the
stylessection - The RPN column references the
rpndecorator - The row header references the
rowHeaderRpnNewdecorator
Related Documentation
- Conditional Formatting — Apply styling based on complex conditions
- CSS Classes — Complete list of available CSS classes
- Item Colors — Color configuration for row items
- Configure Cell Styles — How-to guide for cell decoration
Sources
Sources
KB Articles
- Configure the style of row header
- Configure cell / column styles (colors, fonts, …)
- Collect multiple link columns into one column
AppConfig.tsrisksheet.jsonAppConfigHelper.tsExportToExcel.tsCellPreviewFormatter.ts