---
title: "Single Row Selection"
framework: vue
version: "36.1.0"
---

# Single Row Selection

Enable users to select a single row within a grid.

## Enabling Single Row Selection

To enable single row selection set `rowSelection.mode` to `'singleRow'`.

```ts
<ag-grid-vue
    :rowSelection="rowSelection"
    /* other grid options ... */>
</ag-grid-vue>

this.rowSelection = {
    mode: 'singleRow'
};
```

The example below uses this configuration to restrict selection to a single row

#### Enabling Row Selection

```ts
import {
  createApp,
  defineComponent,
  onBeforeMount,
  ref,
  shallowRef,
} from "vue";
import { AgGridVue } from "ag-grid-vue3";
import {
  ClientSideRowModelModule,
  ColDef,
  ColGroupDef,
  GridApi,
  GridOptions,
  GridReadyEvent,
  GridState,
  GridStateModule,
  ModuleRegistry,
  RowSelectionModule,
  RowSelectionOptions,
  enableDevValidations,
} from "ag-grid-community";
import {
  ColumnMenuModule,
  ColumnsToolPanelModule,
  ContextMenuModule,
  RowGroupingModule,
} from "ag-grid-enterprise";
import { IOlympicData } from "./interfaces";
if (process.env.NODE_ENV !== "production") {
  enableDevValidations();
}

ModuleRegistry.registerModules([
  RowSelectionModule,
  GridStateModule,
  ClientSideRowModelModule,
  ColumnsToolPanelModule,
  ColumnMenuModule,
  ContextMenuModule,
  RowGroupingModule,
]);

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"
      :initialState="initialState"
      :rowData="rowData"></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: "year", maxWidth: 90 },
      { field: "sport", minWidth: 150 },
      { field: "gold" },
      { field: "silver" },
      { field: "bronze" },
    ]);
    const defaultColDef = ref<ColDef>({
      flex: 1,
      minWidth: 100,
    });
    const rowSelection = ref<RowSelectionOptions | "single" | "multiple">({
      mode: "singleRow",
    });
    const initialState = ref<GridState>({
      rowSelection: ["2"],
    });
    const rowData = ref<IOlympicData[]>(null);

    const onGridReady = (params: GridReadyEvent) => {
      gridApi.value = params.api;

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

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

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

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

[Live example: Enabling Row Selection](https://www.ag-grid.com/examples/row-selection-single-row/enabling-row-selection/vue3)

Deselect a row by clicking its checkbox. Alternatively, you can do this via the keyboard by focusing the row and pressing the `␣ Space` key.

## Removing Selection Checkboxes

To prevent any row selection checkboxes from being rendered, set `rowSelection.checkboxes` to `false`. You will also need to enable click selection by setting `enableClickSelection: true`.

```ts
<ag-grid-vue
    :rowSelection="rowSelection"
    /* other grid options ... */>
</ag-grid-vue>

this.rowSelection = {
    mode: 'singleRow',
    checkboxes: false,
    enableClickSelection: true,
};
```

#### Disabling Checkboxes

```ts
import {
  createApp,
  defineComponent,
  onBeforeMount,
  ref,
  shallowRef,
} from "vue";
import { AgGridVue } from "ag-grid-vue3";
import {
  ClientSideRowModelModule,
  ColDef,
  ColGroupDef,
  GridApi,
  GridOptions,
  GridReadyEvent,
  GridState,
  GridStateModule,
  ModuleRegistry,
  RowSelectionModule,
  RowSelectionOptions,
  enableDevValidations,
} from "ag-grid-community";
import {
  ColumnMenuModule,
  ColumnsToolPanelModule,
  ContextMenuModule,
  RowGroupingModule,
} from "ag-grid-enterprise";
import { IOlympicData } from "./interfaces";
if (process.env.NODE_ENV !== "production") {
  enableDevValidations();
}

ModuleRegistry.registerModules([
  RowSelectionModule,
  GridStateModule,
  ClientSideRowModelModule,
  ColumnsToolPanelModule,
  ColumnMenuModule,
  ContextMenuModule,
  RowGroupingModule,
]);

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"
      :initialState="initialState"
      :rowData="rowData"></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: "year", maxWidth: 90 },
      { field: "sport", minWidth: 150 },
      { field: "gold" },
      { field: "silver" },
      { field: "bronze" },
    ]);
    const defaultColDef = ref<ColDef>({
      flex: 1,
      minWidth: 100,
    });
    const rowSelection = ref<RowSelectionOptions | "single" | "multiple">({
      mode: "singleRow",
      checkboxes: false,
      enableClickSelection: true,
    });
    const initialState = ref<GridState>({
      rowSelection: ["2"],
    });
    const rowData = ref<IOlympicData[]>(null);

    const onGridReady = (params: GridReadyEvent) => {
      gridApi.value = params.api;

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

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

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

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

[Live example: Disabling Checkboxes](https://www.ag-grid.com/examples/row-selection-single-row/removing-selection-checkboxes/vue3)

> **Note**
>
> Setting `rowSelection.checkboxes` to the boolean `false` removes the checkboxes entirely. Passing a function instead keeps the checkboxes present and enables or disables them per row: a selectable row for which the function returns `false` shows a disabled checkbox rather than removing it.
>
> For rows where both `isRowSelectable` and `rowSelection.checkboxes` return `false`, checkboxes will be hidden, rather than disabled.

## Configure Selectable Rows

It is possible to specify which rows can be selected via the `rowSelection.isRowSelectable` callback function.

For instance if we only wanted to allow selection for rows where the 'year' property is less than 2007, we could implement the following:

```ts
<ag-grid-vue
    :rowSelection="rowSelection"
    /* other grid options ... */>
</ag-grid-vue>

this.rowSelection = {
    mode: 'singleRow',
    isRowSelectable: (rowNode) => rowNode.data ? rowNode.data.year < 2007 : false,
    hideDisabledCheckboxes: true
};
```

Rows for which `isRowSelectable` returns `false` cannot be selected at all, whether using the UI or the API.

#### Configuring Selectable Rows

```ts
import {
  createApp,
  defineComponent,
  onBeforeMount,
  ref,
  shallowRef,
} from "vue";
import { AgGridVue } from "ag-grid-vue3";
import "./styles.css";
import {
  ClientSideRowModelModule,
  ColDef,
  ColGroupDef,
  GridApi,
  GridOptions,
  GridReadyEvent,
  ModuleRegistry,
  RowSelectionModule,
  RowSelectionOptions,
  enableDevValidations,
} from "ag-grid-community";
import {
  ColumnMenuModule,
  ColumnsToolPanelModule,
  ContextMenuModule,
  RowGroupingModule,
} from "ag-grid-enterprise";
import { IOlympicData } from "./interfaces";
if (process.env.NODE_ENV !== "production") {
  enableDevValidations();
}

ModuleRegistry.registerModules([
  RowSelectionModule,
  ClientSideRowModelModule,
  ColumnsToolPanelModule,
  ColumnMenuModule,
  ContextMenuModule,
  RowGroupingModule,
]);

function getCheckboxValue(id: string): boolean {
  return document.querySelector<HTMLInputElement>(id)?.checked ?? false;
}

const VueExample = defineComponent({
  template: `
        <div style="height: 100%">
                <div class="example-wrapper">
      <div class="example-header">
        <label>
          <span>Hide disabled checkboxes:</span>
          <input id="toggle-hide-checkbox" type="checkbox" checked="" v-on:change="toggleHideCheckbox()">
          </label>
        </div>
        <ag-grid-vue
          style="width: 100%; height: 100%;"
          @grid-ready="onGridReady"
          :columnDefs="columnDefs"
          :defaultColDef="defaultColDef"
          :rowSelection="rowSelection"
          :rowData="rowData"></ag-grid-vue>
        </div>
        </div>
    `,
  components: {
    "ag-grid-vue": AgGridVue,
  },
  setup(props) {
    const gridApi = shallowRef<GridApi<IOlympicData> | null>(null);
    const columnDefs = ref<ColDef[]>([
      { field: "athlete" },
      { field: "sport" },
      { field: "year", maxWidth: 120 },
    ]);
    const defaultColDef = ref<ColDef>({
      flex: 1,
      minWidth: 100,
    });
    const rowSelection = ref<RowSelectionOptions | "single" | "multiple">({
      mode: "singleRow",
      hideDisabledCheckboxes: true,
      isRowSelectable: (rowNode) =>
        rowNode.data ? rowNode.data.year < 2007 : false,
    });
    const rowData = ref<IOlympicData[]>(null);

    function toggleHideCheckbox() {
      gridApi.value.setGridOption("rowSelection", {
        mode: "singleRow",
        isRowSelectable: (rowNode) =>
          rowNode.data ? rowNode.data.year < 2007 : false,
        hideDisabledCheckboxes: getCheckboxValue("#toggle-hide-checkbox"),
      });
    }
    const onGridReady = (params: GridReadyEvent) => {
      gridApi.value = params.api;

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

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

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

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

[Live example: Configuring Selectable Rows](https://www.ag-grid.com/examples/row-selection-single-row/configure-selectable-rows/vue3)

Note this example uses `hideDisabledCheckboxes` to hide disabled checkboxes, which can be toggled on or off.

## Customising the Checkbox Column

The checkbox column may be customised in a similar way to any other column, by specifying its column definition in the `selectionColumnDef` grid option.

| Property | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| `selectionColumnDef` | `SelectionColumnDef` |  |  | Configure the selection column, used for displaying checkboxes. Note that due to the nature of this column, this type is a subset of `ColDef`, which does not support several normal column features such as editing, pivoting and grouping. |

The `SelectionColumnDef` allows for a great deal of customisation, including custom renderers, sorting, tooltips and more. The example below demonstrates the following configuration:

- allowing sorting using the default sort order (selected first) via the header menu
- changing the default width of the column
- allowing resizing
- adding some header tooltip text

```ts
<ag-grid-vue
    :selectionColumnDef="selectionColumnDef"
    /* other grid options ... */>
</ag-grid-vue>

this.selectionColumnDef = {
    sortable: true,
    resizable: true,
    width: 100,
    suppressHeaderMenuButton: false,
    headerTooltip: 'Checkboxes indicate selection',
};
```

#### Customising Checkbox Column

```ts
import {
  createApp,
  defineComponent,
  onBeforeMount,
  ref,
  shallowRef,
} from "vue";
import { AgGridVue } from "ag-grid-vue3";
import {
  ClientSideRowModelModule,
  ColDef,
  ColGroupDef,
  GridApi,
  GridOptions,
  GridReadyEvent,
  ModuleRegistry,
  RowSelectionModule,
  RowSelectionOptions,
  SelectionColumnDef,
  TooltipModule,
  enableDevValidations,
} from "ag-grid-community";
import {
  ColumnMenuModule,
  ColumnsToolPanelModule,
  ContextMenuModule,
  RowGroupingModule,
} from "ag-grid-enterprise";
import { IOlympicData } from "./interfaces";
if (process.env.NODE_ENV !== "production") {
  enableDevValidations();
}

ModuleRegistry.registerModules([
  RowSelectionModule,
  TooltipModule,
  ClientSideRowModelModule,
  ColumnsToolPanelModule,
  ColumnMenuModule,
  ContextMenuModule,
  RowGroupingModule,
]);

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"
      :selectionColumnDef="selectionColumnDef"
      :rowData="rowData"></ag-grid-vue>
        </div>
    `,
  components: {
    "ag-grid-vue": AgGridVue,
  },
  setup(props) {
    const gridApi = shallowRef<GridApi<IOlympicData> | null>(null);
    const columnDefs = ref<ColDef[]>([
      { field: "athlete" },
      { field: "sport" },
      { field: "year", maxWidth: 120 },
    ]);
    const defaultColDef = ref<ColDef>({
      flex: 1,
      minWidth: 100,
    });
    const rowSelection = ref<RowSelectionOptions | "single" | "multiple">({
      mode: "singleRow",
    });
    const selectionColumnDef = ref<SelectionColumnDef>({
      sortable: true,
      resizable: true,
      width: 100,
      suppressHeaderMenuButton: false,
      headerTooltip: "Checkboxes indicate selection",
    });
    const rowData = ref<IOlympicData[]>(null);

    const onGridReady = (params: GridReadyEvent) => {
      gridApi.value = params.api;

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

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

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

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

[Live example: Customising Checkbox Column](https://www.ag-grid.com/examples/row-selection-single-row/customise-checkbox-column/vue3)

> **Note**
>
> When sorting by the checkbox column, selecting a new row will not automatically update the row order, see [Change Detection](https://www.ag-grid.com/vue-data-grid/change-detection/#change-detection-and-sorting-filtering-grouping) for more information.

> **Note**
>
> The checkbox column is sized statically, and is therefore not affected by [Auto-Sizing](https://www.ag-grid.com/vue-data-grid/column-sizing/#auto-sizing-columns).

## Enable Click Selection & Deselection

The `rowSelection.enableClickSelection` property configures whether a row's selection state will be impacted when the row is clicked.

| Property | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| `enableClickSelection` | `boolean \| 'enableDeselection' \| 'enableSelection'` |  | `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. |

This is typically used when [Checkbox Selection](#removing-selection-checkboxes) is disabled, though both can be enabled simultaneously if desired. Click-selection and deselection can be enabled by setting `enableClickSelection` to `true`, otherwise they may be enabled separately using the values `'enableSelection'` and `'enableDeselection'`.

```ts
<ag-grid-vue
    :rowSelection="rowSelection"
    /* other grid options ... */>
</ag-grid-vue>

this.rowSelection = {
    mode: 'singleRow',
    enableClickSelection: true,
};
```

The example below demonstrates the three possible configurations for this property, as well as the behaviour when it is disabled. Click a row to select it, or `^ Ctrl`-click a row to deselect it. Use the select element to switch between modes.

#### Disable Click Selection

```ts
import {
  createApp,
  defineComponent,
  onBeforeMount,
  ref,
  shallowRef,
} from "vue";
import { AgGridVue } from "ag-grid-vue3";
import "./styles.css";
import {
  ClientSideRowModelModule,
  ColDef,
  ColGroupDef,
  GridApi,
  GridOptions,
  GridReadyEvent,
  ModuleRegistry,
  RowSelectionModule,
  RowSelectionOptions,
  enableDevValidations,
} from "ag-grid-community";
import {
  ColumnMenuModule,
  ColumnsToolPanelModule,
  ContextMenuModule,
  RowGroupingModule,
} from "ag-grid-enterprise";
import { IOlympicData } from "./interfaces";
if (process.env.NODE_ENV !== "production") {
  enableDevValidations();
}

ModuleRegistry.registerModules([
  RowSelectionModule,
  ClientSideRowModelModule,
  ColumnsToolPanelModule,
  ColumnMenuModule,
  ContextMenuModule,
  RowGroupingModule,
]);

const VueExample = defineComponent({
  template: `
        <div style="height: 100%">
                <div class="example-wrapper">
      <div class="example-header">
        <label>
          <span>Enable Click Selection: </span>
          <select id="select-enable" v-on:change="onEnableClickSelection()">
            <option value="true">true</option>
            <option value="enableSelection">enableSelection</option>
            <option value="enableDeselection">enableDeselection</option>
            <option value="false">false</option>
          </select>
        </label>
      </div>
      <ag-grid-vue
        style="width: 100%; height: 100%;"
        @grid-ready="onGridReady"
        :columnDefs="columnDefs"
        :defaultColDef="defaultColDef"
        :rowSelection="rowSelection"
        :rowData="rowData"></ag-grid-vue>
      </div>
        </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: "singleRow",
      enableClickSelection: true,
    });
    const rowData = ref<IOlympicData[]>(null);

    function onEnableClickSelection() {
      const value =
        document.querySelector<HTMLSelectElement>("#select-enable")?.value;
      gridApi.value.setGridOption("rowSelection", {
        mode: "singleRow",
        enableClickSelection:
          value === "true" ? true : value === "false" ? false : (value as any),
      });
    }
    const onGridReady = (params: GridReadyEvent) => {
      gridApi.value = params.api;

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

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

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

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

[Live example: Disable Click Selection](https://www.ag-grid.com/examples/row-selection-single-row/suppress-click-selection/vue3)

> **Note**
>
> Note that deselection is still possible using the `␣ Space` key or when checkboxes are enabled by clicking a selected checkbox.

## API Reference

See the full list of configuration options available in `'singleRow'` mode.

| Property | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| `mode` | `'singleRow'` |  |  | 'singleRow' |
| `enableClickSelection` | `boolean \| 'enableDeselection' \| 'enableSelection'` |  | `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. |
| `checkboxes` | `boolean \| CheckboxSelectionCallback` |  | `true` | Set to `true` or return `true` from the callback to render a selection checkbox. |
| `checkboxLocation` | `CheckboxLocation` |  | `'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. |
| `hideDisabledCheckboxes` | `boolean` |  | `false` | Set to `true` to hide a disabled checkbox when row is not selectable and checkboxes are enabled. |
| `isRowSelectable` | `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. |
| `copySelectedRows` | `boolean` |  | `false` | When enabled and a row is selected, the copy action should copy the entire row, rather than just the focused cell |
| `enableSelectionWithoutKeys` | `boolean` |  | `false` | Set to `true` to allow (possibly multiple) rows to be selected and deselected using single click or touch. |
| `masterSelects` | `'self' \| 'detail'` |  | `'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. |

## Row Selection with Enterprise Features

Row selection works with row grouping, tree data, and the server-side row model. See the relevant documentation sections:

- [Row Group Selection](https://www.ag-grid.com/vue-data-grid/grouping-row-selection/)
- [Tree Data Selection](https://www.ag-grid.com/vue-data-grid/tree-data-selection/)
- [Server-Side Row Model Selection](https://www.ag-grid.com/vue-data-grid/server-side-model-selection/)
