Selection API Reference for Single and Multi-Row Selection
The row selection state can be saved and restored as part of Grid State.
Configuration API Copy Link Single Row Mode Copy Link'singleRow'
'singleRow'
boolean | 'enableDeselection' | 'enableSelection'
default: false
Modifies the selection behaviour when clicking a row. Choosing 'enableSelection'
allows selection of a row by clicking the row itself. Choosing 'enableDeselection'
allows deselection of a row by CTRL-clicking the row itself. Choosing true
allows both selection of a row by clicking and deselection of a row by CTRL-clicking. Choosing false
prevents rows from being selected or deselected by clicking.
boolean | CheckboxSelectionCallback
default: true
Set to true
or return true
from the callback to render a selection checkbox.
CheckboxLocation
default: 'selectionColumn'
Configure where checkboxes are displayed. Choosing 'selectionColumn' displays checkboxes in a dedicated selection column. Choosing 'autoGroupColumn' displays checkboxes in the autoGroupColumn. This applies to row checkboxes and header checkboxes.
boolean
default: false
Set to true
to hide a disabled checkbox when row is not selectable and checkboxes are enabled.
IsRowSelectable
Callback to be used to determine which rows are selectable. By default rows are selectable, so return false
to make a row non-selectable.
boolean
default: false
When enabled and a row is selected, the copy action should copy the entire row, rather than just the focused cell
boolean
default: false
Set to true
to allow (possibly multiple) rows to be selected and deselected using single click or touch.
'self' | 'detail'
default: 'self'
Determines the selection behaviour of master rows with respect to their detail cells. When set to 'self'
, selecting the master row has no effect on the selection state of the detail row. When set to 'detail'
, selecting the master row behaves the same as the header checkbox of the detail grid.
'multiRow'
'multiRow'
GroupSelectionMode
default: 'self'
Determine group selection behaviour
SelectAllMode
default: 'all'
Determines how "select all" behaviour works. This controls header checkbox selection.
boolean
default: true
If true
a 'select all' checkbox will be put into the header.
boolean | 'enableDeselection' | 'enableSelection'
default: false
Modifies the selection behaviour when clicking a row. Choosing 'enableSelection'
allows selection of a row by clicking the row itself. Choosing 'enableDeselection'
allows deselection of a row by CTRL-clicking the row itself. Choosing true
allows both selection of a row by clicking and deselection of a row by CTRL-clicking. Choosing false
prevents rows from being selected or deselected by clicking.
boolean | CheckboxSelectionCallback
default: true
Set to true
or return true
from the callback to render a selection checkbox.
CheckboxLocation
default: 'selectionColumn'
Configure where checkboxes are displayed. Choosing 'selectionColumn' displays checkboxes in a dedicated selection column. Choosing 'autoGroupColumn' displays checkboxes in the autoGroupColumn. This applies to row checkboxes and header checkboxes.
boolean
default: false
Set to true
to hide a disabled checkbox when row is not selectable and checkboxes are enabled.
IsRowSelectable
Callback to be used to determine which rows are selectable. By default rows are selectable, so return false
to make a row non-selectable.
boolean
default: false
When enabled and a row is selected, the copy action should copy the entire row, rather than just the focused cell
boolean
default: false
Set to true
to allow (possibly multiple) rows to be selected and deselected using single click or touch.
'self' | 'detail'
default: 'self'
Determines the selection behaviour of master rows with respect to their detail cells. When set to 'self'
, selecting the master row has no effect on the selection state of the detail row. When set to 'detail'
, selecting the master row behaves the same as the header checkbox of the detail grid.
There are two events with regards to selection, illustrated in the example below:
RowSelectedEvent
Row is selected or deselected. The event contains the node in question, so call the node's isSelected()
method to see if it was just selected or deselected.
SelectionChangedEvent
Row selection is changed. Use the selectedNodes
field to get the list of selected nodes at the time of the event. When using the SSRM, selectedNodes
will be null
when selecting all nodes. Instead, refer to the serverSideState
field.
The example below has configured messages to be logged to the developer console on both these events firing. Click a row while the developer console is open to see an illustration of the events.
Node Selection API Copy LinkTo select rows programmatically, use the node.setSelected(params)
method.
Function
Select (or deselect) the node.
newValue
- true
for selection, false
for deselection.clearSelection
- If selecting, then passing true
will select the node exclusively (i.e. NOT do multi select). If doing deselection, clearSelection
has no impact.Function
Returns:
true
if node is selected.false
if the node isn't selected.undefined
if it's partially selected (group where not all children are selected).
node.setSelected(true);
node.setSelected(true, true);
node.setSelected(false);
const selected = node.isSelected();
The isSelected()
method returns true
if the node is selected, or false
if it is not selected. If the node is a group node and the group selection is set to 'children'
, this will return true
if all child (and grandchild) nodes are selected, false
if all unselected, or undefined
if a mixture.
The grid API has the following methods for selection:
Function
Select all rows. By default this ignores filtering, expansion and pagination settings. Pass the appropriate select all mode as an argument in order to select only rows that satisfy the filter, or those rows on the current page. mode
: SelectAll mode to use. See SelectAllMode
source
: Source property that will appear in the selectionChanged
event, defaults to 'apiSelectAll'
Function
Clear all row selections. By default this ignores filtering, expansion and pagination settings. Pass the appropriate select all mode as an argument in order to select only rows that satisfy the filter, or those rows on the current page. mode
: SelectAll mode to use. See SelectAllMode
source
: Source property that will appear in the selectionChanged
event, defaults to 'apiSelectAll'
Function
Returns an unsorted list of selected nodes. Getting the underlying node (rather than the data) is useful when working with tree / aggregated data, as the node can be traversed.
RowSelectionModuleFunction
Returns an unsorted list of selected rows (i.e. row data that you provided).
RowSelectionModuleFunction
Set all of the provided nodes selection state to the provided value.
RowSelectionModuleIf you want to select only the filtered rows, you could do this using the following:
const nodes = [];
api.forEachNodeAfterFilter(node => {
nodes.push(node);
});
api.setNodesSelected({ nodes, newValue: true });
Next up Copy Link
Continue to the next section to learn about Cell Selection.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4