---
title: "Row Numbers"
enterprise: true
framework: javascript
version: "36.1.0"
---

# 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: [`RowNumbersModule`](https://www.ag-grid.com/javascript-data-grid/modules/). |

```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";

// Enable extended validations only for development
if (process.env.NODE_ENV !== "production") {
  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/examples/row-numbers/row-numbers-default/typescript)

## Cell Selection

When the grid is configured with [Cell Selection](https://www.ag-grid.com/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";

// Enable extended validations only for development
if (process.env.NODE_ENV !== "production") {
  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/examples/row-numbers/row-numbers-cell-selection/typescript)

### Suppressing 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.

```js
const gridOptions = {
    rowNumbers: {
        suppressCellSelectionIntegration: true
    },
    cellSelection: 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 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";

// Enable extended validations only for development
if (process.env.NODE_ENV !== "production") {
  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/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/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/javascript-data-grid/csv-export/) or [Excel Export](https://www.ag-grid.com/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` |  |  | 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";

// Enable extended validations only for development
if (process.env.NODE_ENV !== "production") {
  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/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. |
| `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` Module: [`ContextMenuModule`](https://www.ag-grid.com/javascript-data-grid/modules/). |
| `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. |
| `tooltipField` | `ColDefField` |  |  | The field of the tooltip to apply to the cell. When the column is grouped, group rows in the generated group column inherit this value. @agModule `TooltipModule` Module: [`TooltipModule`](https://www.ag-grid.com/javascript-data-grid/modules/). |
| `tooltipValueGetter` | `TooltipValueGetterFunc` |  |  | Callback that should return the string to use for a tooltip, `tooltipField` takes precedence if set. If using a custom `tooltipComponent` you may return any custom value to be passed to your tooltip component. When the column is grouped, group rows in the generated group column inherit this callback. @agModule `TooltipModule` Module: [`TooltipModule`](https://www.ag-grid.com/javascript-data-grid/modules/). |
| `tooltipComponentSelector` | `TooltipComponentSelectorFunc` |  |  | Callback to select which tooltip component to be used for a given row within the same column. @agModule `TooltipModule` Module: [`TooltipModule`](https://www.ag-grid.com/javascript-data-grid/modules/). |
| `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. |
