---
product: "AG Grid"
title: "Row Selection API Reference"
description: "Selection API Reference for Single and Multi-Row Selection in the Vue Table."
framework: vue
version: "36.2.0"
related:
    - title: "Single Row Selection"
      url: "https://www.ag-grid.com/archive/36.2.0/vue-data-grid/row-selection-single-row/"
    - title: "Multi-Row Selection"
      url: "https://www.ag-grid.com/archive/36.2.0/vue-data-grid/row-selection-multi-row/"
llms: "https://www.ag-grid.com/archive/36.2.0/llms.txt"
---

# Row Selection API Reference

Selection API Reference for Single and Multi-Row Selection

> **Note**
>
> The row selection state can be saved and restored as part of [Grid State](https://www.ag-grid.com/archive/36.2.0/vue-data-grid/grid-state/).

## Configuration API

### Single Row Mode

| Property | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| `mode` | `'singleRow'` |  |  |  |
| `enableClickSelection` | `boolean \| 'enableDeselection' \| 'enableSelection'` |  |  |  |
| `checkboxes` | `boolean \| CheckboxSelectionCallback` |  |  |  |
| `checkboxLocation` | `CheckboxLocation` |  |  |  |
| `hideDisabledCheckboxes` | `boolean` |  |  |  |
| `isRowSelectable` | `IsRowSelectable` |  |  |  |
| `copySelectedRows` | `boolean` |  |  |  |
| `enableSelectionWithoutKeys` | `boolean` |  |  |  |
| `masterSelects` | `'self' \| 'detail'` |  |  |  |

### Multi-Row Mode

| Property | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| `mode` | `'multiRow'` |  |  |  |
| `groupSelects` | `GroupSelectionMode` |  |  |  |
| `selectAll` | `SelectAllMode` |  |  |  |
| `headerCheckbox` | `boolean` |  |  |  |
| `ctrlASelectsRows` | `boolean` |  |  |  |
| `enableClickSelection` | `boolean \| 'enableDeselection' \| 'enableSelection'` |  |  |  |
| `checkboxes` | `boolean \| CheckboxSelectionCallback` |  |  |  |
| `checkboxLocation` | `CheckboxLocation` |  |  |  |
| `hideDisabledCheckboxes` | `boolean` |  |  |  |
| `isRowSelectable` | `IsRowSelectable` |  |  |  |
| `copySelectedRows` | `boolean` |  |  |  |
| `enableSelectionWithoutKeys` | `boolean` |  |  |  |
| `masterSelects` | `'self' \| 'detail'` |  |  |  |

## Selection Events

There are two events with regards to selection, illustrated in the example below:

| Property | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| `rowSelected` | `RowSelectedEvent` |  |  |  |
| `selectionChanged` | `SelectionChangedEvent` |  |  |  |

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.

#### Selection Events

```ts
import {
  createApp,
  defineComponent,
  onBeforeMount,
  ref,
  shallowRef,
} from "vue";
import { AgGridVue } from "ag-grid-vue3";
import {
  ClientSideRowModelModule,
  ColDef,
  ColGroupDef,
  GridApi,
  GridOptions,
  GridReadyEvent,
  ModuleRegistry,
  RowSelectedEvent,
  RowSelectionModule,
  RowSelectionOptions,
  SelectionChangedEvent,
  enableDevValidations,
} from "ag-grid-community";
import { IOlympicData } from "./interfaces";

if (process.env.NODE_ENV !== "production") {
  // Enable extended validations only for development
  enableDevValidations();
}

ModuleRegistry.registerModules([RowSelectionModule, ClientSideRowModelModule]);

const VueExample = defineComponent({
  template: `
        <div style="height: 100%">
                <ag-grid-vue
      style="width: 100%; height: 100%;"
      @grid-ready="onGridReady"
      :columnDefs="columnDefs"
      :defaultColDef="defaultColDef"
      :rowSelection="rowSelection"
      :rowData="rowData"
      @row-selected="onRowSelected"
      @selection-changed="onSelectionChanged"></ag-grid-vue>
        </div>
    `,
  components: {
    "ag-grid-vue": AgGridVue,
  },
  setup(props) {
    const gridApi = shallowRef<GridApi<IOlympicData> | null>(null);
    const columnDefs = ref<ColDef[]>([
      { field: "athlete", minWidth: 150 },
      { field: "age", maxWidth: 90 },
      { field: "country", minWidth: 150 },
      { field: "year", maxWidth: 90 },
      { field: "date", minWidth: 150 },
      { field: "sport", minWidth: 150 },
      { field: "gold" },
      { field: "silver" },
      { field: "bronze" },
      { field: "total" },
    ]);
    const defaultColDef = ref<ColDef>({
      flex: 1,
      minWidth: 100,
    });
    const rowSelection = ref<RowSelectionOptions | "single" | "multiple">({
      mode: "multiRow",
      headerCheckbox: false,
    });
    const rowData = ref<IOlympicData[]>(null);

    function onRowSelected(event: RowSelectedEvent) {
      console.log(
        "row " +
          event.node.data.athlete +
          " selected = " +
          event.node.isSelected(),
      );
    }
    function onSelectionChanged(event: SelectionChangedEvent) {
      const rowCount = event.selectedNodes?.length;
      console.log("selection changed, " + rowCount + " rows selected");
    }
    const onGridReady = (params: GridReadyEvent) => {
      gridApi.value = params.api;

      const updateData = (data) => (rowData.value = data);

      fetch("https://www.ag-grid.com/example-assets/olympic-winners.json")
        .then((resp) => resp.json())
        .then((data) => updateData(data));
    };

    return {
      gridApi,
      columnDefs,
      defaultColDef,
      rowSelection,
      rowData,
      onGridReady,
      onRowSelected,
      onSelectionChanged,
    };
  },
});

const app = createApp(VueExample);
app.mount("#app");
```

[Live example: Selection Events](https://www.ag-grid.com/archive/36.2.0/examples/row-selection-api-reference/selection-events/vue3/)

## Node Selection API

To select rows programmatically, use the `node.setSelected(params)` method.

| Property | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| `setSelected` | `Function` |  |  |  |
| `isSelected` | `Function` |  |  |  |

For example:

```ts
// set selected, keep any other selections
node.setSelected(true);

// set selected, exclusively, remove any other selections
node.setSelected(true, true);

// un-select
node.setSelected(false);

// check status of node selection
const selected = node.isSelected();
```

## Grid Selection API

The grid API has the following methods for selection:

| Property | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| `selectAll` | `Function` |  |  |  |
| `deselectAll` | `Function` |  |  |  |
| `getSelectedNodes` | `Function` |  |  |  |
| `getSelectedRows` | `Function` |  |  |  |
| `setNodesSelected` | `Function` |  |  |  |

If you want to select only the filtered rows, you could do this using the following:

```js
// loop through each node after filter
const nodes = [];
api.forEachNodeAfterFilter(node => {
    nodes.push(node);
});
api.setNodesSelected({ nodes, newValue: true });
```
