---
product: "AG Grid"
title: "Row Numbers"
description: "The Row Numbers Feature adds a Column that is always present at the start of the grid where each cell of this column will work as a row header. The following example demonstrates the grid with Row Numbers and no additional configuration."
enterprise: true
framework: javascript
version: "36.3.0"
related:
    - title: "Row Data"
      url: "https://www.ag-grid.com/archive/36.3.0/javascript-data-grid/row-ids/"
    - title: "Row Sorting"
      url: "https://www.ag-grid.com/archive/36.3.0/javascript-data-grid/row-sorting/"
    - title: "Row Spanning"
      url: "https://www.ag-grid.com/archive/36.3.0/javascript-data-grid/row-spanning/"
    - title: "Row Pinning"
      url: "https://www.ag-grid.com/archive/36.3.0/javascript-data-grid/row-pinning/"
    - title: "Row Height"
      url: "https://www.ag-grid.com/archive/36.3.0/javascript-data-grid/row-height/"
    - title: "Styling Rows"
      url: "https://www.ag-grid.com/archive/36.3.0/javascript-data-grid/row-styles/"
    - title: "Row Pagination"
      url: "https://www.ag-grid.com/archive/36.3.0/javascript-data-grid/row-pagination/"
    - title: "Accessing Rows"
      url: "https://www.ag-grid.com/archive/36.3.0/javascript-data-grid/accessing-data/"
    - title: "Row Dragging"
      url: "https://www.ag-grid.com/archive/36.3.0/javascript-data-grid/row-dragging/"
    - title: "Full Width Rows"
      url: "https://www.ag-grid.com/archive/36.3.0/javascript-data-grid/full-width-rows/"
llms: "https://www.ag-grid.com/archive/36.3.0/llms.txt"
---

# Row Numbers

The Row Numbers Feature adds a Column that is always present at the start of the grid where each cell of this column will work as a row header. The following example demonstrates the grid with Row Numbers and no additional configuration.

To enable Row Numbers, set the grid option `rowNumbers = true`.

| Property | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| `rowNumbers` | `boolean \| RowNumbersOptions` |  | `false` | Configure the Row Numbers Feature. [Module](https://www.ag-grid.com/archive/36.3.0/javascript-data-grid/modules/): `RowNumbersModule`. |

```js
const gridOptions = {
    rowNumbers: true,

    // other grid options ...
}
```

#### Row Numbers

```ts
import {
  ClientSideRowModelModule,
  ColDef,
  GridApi,
  GridOptions,
  ModuleRegistry,
  createGrid,
  enableDevValidations,
} from "ag-grid-community";
import { RowNumbersModule } from "ag-grid-enterprise";
import { IOlympicData } from "./interfaces";

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

ModuleRegistry.registerModules([ClientSideRowModelModule, RowNumbersModule]);

const columnDefs: ColDef[] = [
  { field: "athlete" },
  { field: "country" },
  { field: "sport" },
  { field: "year" },
  { field: "gold" },
  { field: "silver" },
  { field: "bronze" },
];

let gridApi: GridApi<IOlympicData>;

const gridOptions: GridOptions<IOlympicData> = {
  defaultColDef: {
    flex: 1,
    minWidth: 100,
  },
  rowNumbers: true,
  columnDefs: columnDefs,
  rowData: null,
};

const gridDiv = document.querySelector<HTMLElement>("#myGrid")!;
gridApi = createGrid(gridDiv, gridOptions);

fetch("https://www.ag-grid.com/example-assets/olympic-winners.json")
  .then((response) => response.json())
  .then((data) => {
    gridApi!.setGridOption("rowData", data);
  });
```

[Live example: Row Numbers](https://www.ag-grid.com/archive/36.3.0/examples/row-numbers/row-numbers-default/typescript/)

## Cell Selection

When the grid is configured with [Cell Selection](https://www.ag-grid.com/archive/36.3.0/javascript-data-grid/cell-selection/), clicking a Row Number will select all the currently visible cells in the row.

```js
const gridOptions = {
    rowNumbers: true,
    cellSelection: true,

    // other grid options ...
}
```

#### Row Numbers with Cell Selection

```ts
import {
  ClientSideRowModelModule,
  ColDef,
  GridApi,
  GridOptions,
  ModuleRegistry,
  createGrid,
  enableDevValidations,
} from "ag-grid-community";
import { CellSelectionModule, RowNumbersModule } from "ag-grid-enterprise";
import { IOlympicData } from "./interfaces";

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

ModuleRegistry.registerModules([
  ClientSideRowModelModule,
  RowNumbersModule,
  CellSelectionModule,
]);

const columnDefs: ColDef[] = [
  { field: "athlete" },
  { field: "country" },
  { field: "sport" },
  { field: "year" },
  { field: "gold" },
  { field: "silver" },
  { field: "bronze" },
];

let gridApi: GridApi<IOlympicData>;

const gridOptions: GridOptions<IOlympicData> = {
  defaultColDef: {
    flex: 1,
    minWidth: 100,
  },
  cellSelection: true,
  rowNumbers: true,
  columnDefs: columnDefs,
  rowData: null,
};

const gridDiv = document.querySelector<HTMLElement>("#myGrid")!;
gridApi = createGrid(gridDiv, gridOptions);

fetch("https://www.ag-grid.com/example-assets/olympic-winners.json")
  .then((response) => response.json())
  .then((data) => {
    gridApi!.setGridOption("rowData", data);
  });
```

[Live example: Row Numbers with Cell Selection](https://www.ag-grid.com/archive/36.3.0/examples/row-numbers/row-numbers-cell-selection/typescript/)

## Row Selection

When the grid is configured with [Row Selection](https://www.ag-grid.com/archive/36.3.0/javascript-data-grid/row-selection/) and click selection is enabled via `rowSelection.enableClickSelection`, clicking a Row Number selects the row.

```js
const gridOptions = {
    rowNumbers: true,
    rowSelection: {
        mode: 'multiRow',
        enableClickSelection: true
    },

    // other grid options ...
}
```

When [Cell Selection](https://www.ag-grid.com/archive/36.3.0/javascript-data-grid/cell-selection/) is enabled as well, a Row Number click does both: it selects all the cells in the row and the row itself.

### Suppressing Cell Selection Integration

By default, clicking a row number selects a cell range including all the cells in the row. To prevent this behaviour use the `suppressCellSelectionIntegration` option, which leaves only the [Row Selection](https://www.ag-grid.com/archive/36.3.0/javascript-data-grid/row-selection/) behaviour so that just the row is selected.

```js
const gridOptions = {
    rowNumbers: {
        suppressCellSelectionIntegration: true
    },
    cellSelection: true,
    rowSelection: {
        mode: 'multiRow',
        enableClickSelection: true
    },

    // other grid options ...
}
```

| Property | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| `suppressCellSelectionIntegration` | `boolean` |  | `false` | Set to `true` to prevent selecting all the currently visible cells in the row when clicking a Row Number. |

#### Row Numbers with Row Selection

```ts
import {
  ClientSideRowModelModule,
  ColDef,
  GridApi,
  GridOptions,
  ModuleRegistry,
  RowSelectionModule,
  createGrid,
  enableDevValidations,
} from "ag-grid-community";
import { CellSelectionModule, RowNumbersModule } from "ag-grid-enterprise";
import { IOlympicData } from "./interfaces";

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

ModuleRegistry.registerModules([
  ClientSideRowModelModule,
  RowNumbersModule,
  CellSelectionModule,
  RowSelectionModule,
]);

const columnDefs: ColDef[] = [
  { field: "athlete" },
  { field: "country" },
  { field: "sport" },
  { field: "year" },
  { field: "gold" },
  { field: "silver" },
  { field: "bronze" },
];

let gridApi: GridApi<IOlympicData>;

const gridOptions: GridOptions<IOlympicData> = {
  defaultColDef: {
    flex: 1,
    minWidth: 100,
  },
  cellSelection: true,
  rowSelection: {
    mode: "multiRow",
    enableClickSelection: true,
  },
  rowNumbers: {
    suppressCellSelectionIntegration: true,
  },
  columnDefs: columnDefs,
  rowData: null,
};

const gridDiv = document.querySelector<HTMLElement>("#myGrid")!;
gridApi = createGrid(gridDiv, gridOptions);

fetch("https://www.ag-grid.com/example-assets/olympic-winners.json")
  .then((response) => response.json())
  .then((data) => {
    gridApi!.setGridOption("rowData", data);
  });
```

[Live example: Row Numbers with Row Selection](https://www.ag-grid.com/archive/36.3.0/examples/row-numbers/row-numbers-row-selection/typescript/)

## Context Menu

Right-clicking a Row Number cell opens the [Context Menu](https://www.ag-grid.com/archive/36.3.0/javascript-data-grid/context-menu/). As the cell holds no data of its own, the default items are the row-level ones, such as `Export`. The clipboard items (`Cut`, `Copy` and their variants) are included only when there is a cell range or selected rows to copy. Use `rowNumbers.contextMenuItems` to override the items for the Row Numbers Column only.

## Row Resizing

To allow the Row Numbers feature to resize rows, the `enableRowResizer` property can be used.

```js
const gridOptions = {
    rowNumbers: {
        enableRowResizer: true
    },

    // other grid options ...
}
```

| Property | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| `enableRowResizer` | `boolean` |  | `false` | Set to `true` to add a resizer to each Row Number cell that allows row resizing. |

#### Row Numbers Row Resizer

```ts
import {
  ClientSideRowModelModule,
  ColDef,
  GridApi,
  GridOptions,
  ModuleRegistry,
  createGrid,
  enableDevValidations,
} from "ag-grid-community";
import { RowNumbersModule } from "ag-grid-enterprise";
import { IOlympicData } from "./interfaces";

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

ModuleRegistry.registerModules([ClientSideRowModelModule, RowNumbersModule]);

const columnDefs: ColDef[] = [
  { field: "athlete" },
  { field: "country" },
  { field: "sport" },
  { field: "year" },
  { field: "gold" },
  { field: "silver" },
  { field: "bronze" },
];

let gridApi: GridApi<IOlympicData>;

const gridOptions: GridOptions<IOlympicData> = {
  defaultColDef: {
    flex: 1,
    minWidth: 100,
  },
  rowNumbers: {
    enableRowResizer: true,
  },
  columnDefs: columnDefs,
  rowData: null,
};

const gridDiv = document.querySelector<HTMLElement>("#myGrid")!;
gridApi = createGrid(gridDiv, gridOptions);

fetch("https://www.ag-grid.com/example-assets/olympic-winners.json")
  .then((response) => response.json())
  .then((data) => {
    gridApi!.setGridOption("rowData", data);
  });
```

[Live example: Row Numbers Row Resizer](https://www.ag-grid.com/archive/36.3.0/examples/row-numbers/row-numbers-row-resizer/typescript/)

> **Note**
>
> The Row Resizer feature does not work when columns are configured with [Auto Row Height](https://www.ag-grid.com/archive/36.3.0/javascript-data-grid/row-height/#auto-row-height).

### Row Resize Events

The following events are fired when a row resize operation starts and ends.

| Property | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| `rowResizeStarted` | `RowResizeStartedEvent` |  |  | The row resize has started (Row Numbers Feature) |
| `rowResizeEnded` | `RowResizeEndedEvent` |  |  | The row resize has ended (Row Numbers Feature) |

## Value Export

By default, when working with exporters such as [CSV Export](https://www.ag-grid.com/archive/36.3.0/javascript-data-grid/csv-export/) or [Excel Export](https://www.ag-grid.com/archive/36.3.0/javascript-data-grid/excel-export/), the value of the Row Numbers column is not exported. This behaviour can be changed by toggling the `exportRowNumbers` of the export params.

```js
const gridOptions = {
    rowNumbers: true,
    cellSelection: {
        enableHeaderHighlight: true,
        handle: { mode: 'fill' },
    },
    defaultCsvExportParams: {
        exportRowNumbers: true,
    },
    defaultExcelExportParams: {
        exportRowNumbers: true,
    },

    // other grid options ...
}
```

### ExportParams

| Property | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| `exportRowNumbers` | `boolean` |  | `false` | Set to `true` to allow the contents of the Row Numbers column to be exported. |

#### Row Numbers with Export

```ts
import {
  ClientSideRowModelModule,
  ColDef,
  CsvExportModule,
  GridApi,
  GridOptions,
  ModuleRegistry,
  createGrid,
  enableDevValidations,
} from "ag-grid-community";
import {
  CellSelectionModule,
  ContextMenuModule,
  ExcelExportModule,
  RowNumbersModule,
} from "ag-grid-enterprise";
import { IOlympicData } from "./interfaces";

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

ModuleRegistry.registerModules([
  ClientSideRowModelModule,
  RowNumbersModule,
  CellSelectionModule,
  ExcelExportModule,
  CsvExportModule,
  ContextMenuModule,
]);

const columnDefs: ColDef[] = [
  { field: "athlete" },
  { field: "country" },
  { field: "sport" },
  { field: "year" },
  { field: "gold" },
  { field: "silver" },
  { field: "bronze" },
];

let gridApi: GridApi<IOlympicData>;

const gridOptions: GridOptions<IOlympicData> = {
  defaultColDef: {
    flex: 1,
    minWidth: 100,
  },
  rowNumbers: true,
  defaultCsvExportParams: {
    exportRowNumbers: true,
  },
  defaultExcelExportParams: {
    exportRowNumbers: true,
  },
  columnDefs: columnDefs,
  cellSelection: {
    enableHeaderHighlight: true,
    handle: {
      mode: "fill",
    },
  },
  rowData: null,
};

const gridDiv = document.querySelector<HTMLElement>("#myGrid")!;
gridApi = createGrid(gridDiv, gridOptions);

fetch("https://www.ag-grid.com/example-assets/olympic-winners.json")
  .then((response) => response.json())
  .then((data) => {
    gridApi!.setGridOption("rowData", data);
  });
```

[Live example: Row Numbers with Export](https://www.ag-grid.com/archive/36.3.0/examples/row-numbers/row-numbers-export/typescript/)

## Customising Row Numbers

Row Numbers can be customised by providing a `RowNumbersOptions` object to the `rowNumbers` grid option:

| Property | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| `suppressCellSelectionIntegration` | `boolean` |  | `false` | Set to `true` to prevent selecting all the currently visible cells in the row when clicking a Row Number. |
| `enableRowResizer` | `boolean` |  | `false` | Set to `true` to add a resizer to each Row Number cell that allows row resizing. |
| `minWidth` | `number` |  | `60` | The minimum width for the row number column. |
| `width` | `number` |  | `60` | The default width for the row number column. When set, the column never auto-sizes narrower than it, unless `maxWidth` is smaller. Updating `rowNumbers` keeps a width the user has resized the column to, within its new `minWidth` and `maxWidth`, unless the update sets a different `width` of at least `minWidth`. |
| `resizable` | `boolean` |  | `false` | Whether this column is resizable. |
| `contextMenuItems` | `(DefaultMenuItem \| MenuItemDef)[] \| GetContextMenuItems` |  |  | Customise the list of menu items available in the context menu. @agModule `ContextMenuModule` |
| `onCellClicked` | `Function` |  |  | Callback called when a cell is clicked. |
| `onCellContextMenu` | `Function` |  |  | Callback called when a cell is right clicked. |
| `onCellDoubleClicked` | `Function` |  |  | Callback called when a cell is double clicked. |
| `headerComponent` | `any` |  |  | The custom header component to be used for rendering the component header. If none specified the default AG Grid header component is used. See [Header Component](https://www.ag-grid.com/javascript-data-grid/column-headers/) for framework specific implementation detail. |
| `headerComponentParams` | `any` |  |  | The parameters to be passed to the `headerComponent`. |
| `suppressNavigable` | `boolean \| SuppressNavigableCallback` |  | `false` | Set to `true` if this column is not navigable (i.e. cannot be tabbed into), otherwise `false`. Can also be a callback function to have different rows navigable. |
| `tooltip` | `TooltipDefinition` |  |  | Tooltip for the cell. `true` shows the displayed cell value (`valueFormatted` when present, otherwise `value`). `false` disables tooltip content configured on the Column Definition. A string shows static content. A callback resolves the content from the supplied params. When the column is grouped, group rows in the generated group column inherit this value. @agModule `TooltipModule` |
| `tooltipComponentSelector` | `TooltipComponentSelectorFunc` |  |  | Callback to select which tooltip component to be used for a given row within the same column. @agModule `TooltipModule` |
| `valueGetter` | `string \| ValueGetterFunc` |  |  | Function or expression. Gets the value from your data for display. |
| `valueFormatter` | `string \| ValueFormatterFunc` |  |  | A function or expression to format a value, should return a string. |
| `maxWidth` | `number` |  |  | Maximum width in pixels for the cell. |
| `cellRenderer` | `any` |  |  | Provide your own cell Renderer component for this column's cells. See [Cell Renderer](https://www.ag-grid.com/javascript-data-grid/component-cell-renderer/) for framework specific implementation details. |
| `cellRendererSelector` | `CellRendererSelectorFunc` |  |  | Callback to select which cell renderer to be used for a given row within the same column. |
| `cellRendererParams` | `any` |  |  | Params to be passed to the `cellRenderer` component. |
