Single Row Selection
Enable single-row selection by setting the enabled prop of GridSelectableSettings to true and its mode prop to single.
<Grid :selectable="{ enabled: true, mode: 'single' }" />
The following example demonstrates how to enable the single-row selection of the Grid where the select state is handled internally by the Grid.
Checkbox Selection
The Grid supports single-row selection through checkboxes and row clicks.
To configure the checkbox selection:
-
Configure the
GridSelectableSettingsas follows:html<Grid :selectable="{ enabled: true, drag: false, cell: false, mode: 'single' }" > -
Add a column with
columnTypeset tocheckbox. -
Bind the
selectprop and update it in theselectionchangeandheaderselectionchangeevent handlers.
The following example demonstrates single-row checkbox selection with controlled state management.
Persisting Checkbox Selection
The select state object maps dataItemKey values to booleans, so you can serialize it with JSON.stringify and store it in localStorage. When initialized, the example reads the saved selection from storage and passes it to the select prop.
The following example demonstrates this pattern. Use the Save Selection button to write the current selection to localStorage, and Load Selection to read it back. A saved selection also persists after a page refresh.