# Row selection

Row selection chooses targets for bulk actions such as approval, export, or assignment. Unlike cell range selection, it selects an entire order.

Canonical: https://grid.syidax.com/docs/features/row-selection/

<a id="understand"></a>

## How it works and when to use it

Store selections as IDs, not display positions. Selecting a row does not itself delete an order or trigger server processing.

In the code, grid is the Grid element prepared in the installation chapter. Check each example's data and settings, and implement the app functions and server endpoints for your project.

- [Installation and integration · Shared sample data](https://grid.syidax.com/docs/guides/getting-started.md)

<a id="example-1"></a>

## Example 1. Select multiple orders

Configure checkboxes so users can select multiple orders at once.

```javascript
grid.rowSelection = 'multi';
grid.selectionCheckbox = true;
await grid.selectRows(['ORD-0001', 'ORD-0003']);
```

Verify the result: Two orders are selected. Distinguish the displayed scope affected by the header checkbox from selecting all server data.

<a id="example-2"></a>

## Example 2. Read bulk-action targets

Read selected IDs and pass them to your app's confirmation screen.

```javascript
const selectedIds = await grid.getSelectedRowIds();
console.log(selectedIds);
```

Verify the result: The same order IDs remain identifiable after sorting. Connect your UI accordingly, for example by disabling the action button when selection is empty.

<a id="example-3"></a>

## Example 3. Respond to selection changes

Update the selection count and details panel whenever a checkbox changes.

```javascript
grid.addEventListener('selectionChanged', event => console.log(event.detail));
// Clear selection
await grid.selectRows([]);
```

Verify the result: Verify that clearing selection produces an empty result. Do not retain missing IDs or deleted orders as action targets.

<a id="pitfalls"></a>

## Combining features and troubleshooting

Selecting loaded rows cannot represent selection of the entire server data set. Identify when you need the server row model's selection state API.

Read permission and selectability are different policies. Recheck authorization on the server when submitting operations for selected IDs.

<a id="related-api"></a>

## APIs used by this feature

- [rowSelection](https://grid.syidax.com/docs/options/rowSelection.md) — Disables row selection or enables single/multiple selection. Independent of cell range selection.
- [getRowId](https://grid.syidax.com/docs/options/getRowId.md) — Returns a stable, unique row ID. The same business row must retain its ID after sorting, filtering, and editing.
- [selectionCheckbox](https://grid.syidax.com/docs/options/selectionCheckbox.md) — Displays row selection checkboxes.
- [showSelectionCheckbox](https://grid.syidax.com/docs/options/showSelectionCheckbox.md) — Compatibility alias for selection checkboxes. Avoid conflicts with selectionCheckbox.
- [shiftClickAdditive](https://grid.syidax.com/docs/options/shiftClickAdditive.md) — Chooses whether Shift-click range selection adds to the existing selection.
- [selectRows](https://grid.syidax.com/docs/methods/selectRows.md) — Sets selection for specified row IDs. Use stable IDs, not display indices.
- [getSelectedRowIds](https://grid.syidax.com/docs/methods/getSelectedRowIds.md) — Reads selected row IDs. Use dedicated server selection state APIs for server-wide selection.
- [selectionChanged](https://grid.syidax.com/docs/events/selectionChanged.md) — Emitted when row selection changes. Use selected IDs to define bulk-operation targets.

<a id="next"></a>

## Related reading

- [How rows, columns, and IDs relate](https://grid.syidax.com/docs/guides/concepts.md)
- [Connect results and events](https://grid.syidax.com/docs/guides/data-event-access.md)
- [Explore in Features](https://grid.syidax.com/grid/row-selection) — The guide describes which interactions are available to try.
