Clickable Cell Icons
A cell renderer can return a <cell-icon> element to show one of the built-in icons in a cell. The icon works like a button: when the user clicks it (or focuses it and presses Enter or Space), the component raises the Cell Icon Clicked event. You don't need to write any click handling in the renderer.
Clickable cell icons work in Worksheets, Tables, SQL Reports and Table Views.
Example
This renderer shows an icon based on the cell's value. Clicking it raises the Cell Icon Clicked event.
function(eventArgs, services){
// Map your own cell values to icon names. A value that already is an icon name is used as it is.
const iconNames = { 'Open': 'popup', 'Total': 'sum' };
const icon = document.createElement('cell-icon');
icon.setAttribute('name', iconNames[eventArgs.value] ?? eventArgs.value);
icon.setAttribute('title', 'Open details');
return icon;
}
Tip
In the Designer, the Clickable icon sample in the Renderer editor gives you this code to start from.
Icon names
Set the name attribute to one of these names. Names are not case sensitive. An unknown name shows nothing.
| Icon | Icon | Icon |
|---|---|---|
popup |
sum |
calculate-postings |
lookup |
formula |
driver-model |
link |
comment |
counterpart-entity |
party-entity |
periodization |
periodization-custom |
chevrons-right |
open-external |
currency |
plus-minus |
tilde |
sigma |
calendar |
The icon uses the cell's text color, so it stays visible on selected rows and in every theme.
Attributes and properties
name The name of the icon to show. See Icon names.
title The tooltip, also read by screen readers. If you don't set it, the icon name is used.
align
Where the icon sits horizontally in the cell: left, center or right.
valign
Where the icon sits vertically in the cell: top, middle or bottom. This is only visible in rows that are taller than the icon, for example when another column wraps its text.
You can set align and valign as attributes or as properties:
icon.align = 'left';
icon.valign = 'top';
By default the icon is centered in the cell. If the column's Content Alignment is Center or Right, that is used instead. Content Alignment Left is treated as not set, so use icon.align = 'left' to put the icon on the left. align and valign always win over Content Alignment.
Note
The default centering and align/valign apply when the renderer returns the <cell-icon> itself. If you wrap the icon in another element, you control its placement with that element.
The Cell Icon Clicked event
Add an event handler for Cell Icon Clicked on the component to act on the click. The event args contain:
Data The data (row) object of the clicked cell.
Sender.ColumnName The name of the column that was clicked.
CellValue The value of the clicked cell.
IconName
The name of the icon that was clicked.
Example
Use IconName when a column can show different icons, for example to open a different popup per icon:
_state.customerId = Event.Data.CustomerId;
_state.clickedIcon = Event.IconName;