Row Selection in Apex Grid
The Apex grid supports single- and multi-row selection with an optional dedicated checkbox column. Selection works programmatically and via the keyboard, and the checkbox column is purely cosmetic — hiding it does not disable selection.
Enabling selection
grid.selection = {
enabled: true,
mode: 'multiple', // 'single' | 'multiple'
showCheckboxColumn: true,
};
Configuration
type SelectionConfiguration = {
enabled: boolean;
mode?: 'single' | 'multiple';
showCheckboxColumn?: boolean;
};
- mode controls the selection cardinality. Defaults to
'single'. - showCheckboxColumn renders a leading checkbox column. Defaults to
falseforsingle,trueformultiple.
Programmatic API
await grid.selectRow(row);
await grid.deselectRow(row);
await grid.toggleRowSelection(row);
await grid.selectAllRows();
grid.clearSelection();
const isSelected = grid.isRowSelected(row);
grid.selectedRows = [row1, row2]; // setter routes through `rowSelecting`
const current = grid.selectedRows; // getter
Events
- rowSelecting — cancellable; fires before a row's selection state changes. In multi mode, this fires once per affected row.
- rowSelected — fires after the row's selection state has changed.
Use the rowSelecting event to enforce business rules (for example, prevent deselecting the last row) by calling event.preventDefault() inside the handler.
Keyboard
The grid follows the WCAG 2.2 AA grid pattern: Space toggles the focused row, Shift+Space extends the selection range from the anchor, and Ctrl+A selects all rows in multiple mode.