---
title: "Row Numbers"
enterprise: true
framework: react
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/react-data-grid/modules/). |

```jsx
const rowNumbers = true;

<AgGridReact rowNumbers={rowNumbers} />
```

#### Row Numbers

```tsx
"use client";

import React, {
  useCallback,
  useMemo,
  useRef,
  useState,
  StrictMode,
} from "react";
import { createRoot } from "react-dom/client";
import { AgGridReact, AgGridProvider } from "ag-grid-react";
import {
  ClientSideRowModelModule,
  ColDef,
  ColGroupDef,
  GridApi,
  GridOptions,
  ModuleRegistry,
  RowNumbersOptions,
  enableDevValidations,
} from "ag-grid-community";
import { RowNumbersModule } from "ag-grid-enterprise";
import { IOlympicData } from "./interfaces";
import { useFetchJson } from "./useFetchJson";

if (process.env.NODE_ENV !== "production") {
  enableDevValidations();
}

const modules = [ClientSideRowModelModule, RowNumbersModule];

const GridExample = () => {
  const containerStyle = useMemo(() => ({ width: "100%", height: "100%" }), []);
  const gridStyle = useMemo(() => ({ height: "100%", width: "100%" }), []);

  const [columnDefs, setColumnDefs] = useState<ColDef[]>([
    { field: "athlete" },
    { field: "country" },
    { field: "sport" },
    { field: "year" },
    { field: "gold" },
    { field: "silver" },
    { field: "bronze" },
  ]);
  const defaultColDef = useMemo<ColDef>(() => {
    return {
      flex: 1,
      minWidth: 100,
    };
  }, []);

  const { data, loading } = useFetchJson<IOlympicData>(
    "https://www.ag-grid.com/example-assets/olympic-winners.json",
  );

  return (
    <AgGridProvider modules={modules}>
      <div style={containerStyle}>
        <div style={gridStyle}>
          <AgGridReact<IOlympicData>
            rowData={data}
            loading={loading}
            columnDefs={columnDefs}
            defaultColDef={defaultColDef}
            rowNumbers={true}
          />
        </div>
      </div>
    </AgGridProvider>
  );
};

const root = createRoot(document.getElementById("root")!);
root.render(
  <StrictMode>
    <GridExample />
  </StrictMode>,
);
```

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

## Cell Selection

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

```jsx
const rowNumbers = true;
const cellSelection = true;

<AgGridReact
    rowNumbers={rowNumbers}
    cellSelection={cellSelection}
/>
```

#### Row Numbers with Cell Selection

```tsx
"use client";

import React, {
  useCallback,
  useMemo,
  useRef,
  useState,
  StrictMode,
} from "react";
import { createRoot } from "react-dom/client";
import { AgGridReact, AgGridProvider } from "ag-grid-react";
import {
  CellSelectionOptions,
  ClientSideRowModelModule,
  ColDef,
  ColGroupDef,
  GridApi,
  GridOptions,
  ModuleRegistry,
  RowNumbersOptions,
  enableDevValidations,
} from "ag-grid-community";
import { CellSelectionModule, RowNumbersModule } from "ag-grid-enterprise";
import { IOlympicData } from "./interfaces";
import { useFetchJson } from "./useFetchJson";

if (process.env.NODE_ENV !== "production") {
  enableDevValidations();
}

const modules = [
  ClientSideRowModelModule,
  RowNumbersModule,
  CellSelectionModule,
];

const GridExample = () => {
  const containerStyle = useMemo(() => ({ width: "100%", height: "100%" }), []);
  const gridStyle = useMemo(() => ({ height: "100%", width: "100%" }), []);

  const [columnDefs, setColumnDefs] = useState<ColDef[]>([
    { field: "athlete" },
    { field: "country" },
    { field: "sport" },
    { field: "year" },
    { field: "gold" },
    { field: "silver" },
    { field: "bronze" },
  ]);
  const defaultColDef = useMemo<ColDef>(() => {
    return {
      flex: 1,
      minWidth: 100,
    };
  }, []);

  const { data, loading } = useFetchJson<IOlympicData>(
    "https://www.ag-grid.com/example-assets/olympic-winners.json",
  );

  return (
    <AgGridProvider modules={modules}>
      <div style={containerStyle}>
        <div style={gridStyle}>
          <AgGridReact<IOlympicData>
            rowData={data}
            loading={loading}
            columnDefs={columnDefs}
            defaultColDef={defaultColDef}
            cellSelection={true}
            rowNumbers={true}
          />
        </div>
      </div>
    </AgGridProvider>
  );
};

const root = createRoot(document.getElementById("root")!);
root.render(
  <StrictMode>
    <GridExample />
  </StrictMode>,
);
```

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

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

```jsx
const rowNumbers = useMemo(() => { 
	return {
        suppressCellSelectionIntegration: true
    };
}, []);
const cellSelection = true;

<AgGridReact
    rowNumbers={rowNumbers}
    cellSelection={cellSelection}
/>
```

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

```jsx
const rowNumbers = useMemo(() => { 
	return {
        enableRowResizer: true
    };
}, []);

<AgGridReact rowNumbers={rowNumbers} />
```

| 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

```tsx
"use client";

import React, {
  useCallback,
  useMemo,
  useRef,
  useState,
  StrictMode,
} from "react";
import { createRoot } from "react-dom/client";
import { AgGridReact, AgGridProvider } from "ag-grid-react";
import {
  ClientSideRowModelModule,
  ColDef,
  ColGroupDef,
  GridApi,
  GridOptions,
  ModuleRegistry,
  RowNumbersOptions,
  enableDevValidations,
} from "ag-grid-community";
import { RowNumbersModule } from "ag-grid-enterprise";
import { IOlympicData } from "./interfaces";
import { useFetchJson } from "./useFetchJson";

if (process.env.NODE_ENV !== "production") {
  enableDevValidations();
}

const modules = [ClientSideRowModelModule, RowNumbersModule];

const GridExample = () => {
  const containerStyle = useMemo(() => ({ width: "100%", height: "100%" }), []);
  const gridStyle = useMemo(() => ({ height: "100%", width: "100%" }), []);

  const [columnDefs, setColumnDefs] = useState<ColDef[]>([
    { field: "athlete" },
    { field: "country" },
    { field: "sport" },
    { field: "year" },
    { field: "gold" },
    { field: "silver" },
    { field: "bronze" },
  ]);
  const defaultColDef = useMemo<ColDef>(() => {
    return {
      flex: 1,
      minWidth: 100,
    };
  }, []);
  const rowNumbers = useMemo<boolean | RowNumbersOptions>(() => {
    return {
      enableRowResizer: true,
    };
  }, []);

  const { data, loading } = useFetchJson<IOlympicData>(
    "https://www.ag-grid.com/example-assets/olympic-winners.json",
  );

  return (
    <AgGridProvider modules={modules}>
      <div style={containerStyle}>
        <div style={gridStyle}>
          <AgGridReact<IOlympicData>
            rowData={data}
            loading={loading}
            columnDefs={columnDefs}
            defaultColDef={defaultColDef}
            rowNumbers={rowNumbers}
          />
        </div>
      </div>
    </AgGridProvider>
  );
};

const root = createRoot(document.getElementById("root")!);
root.render(
  <StrictMode>
    <GridExample />
  </StrictMode>,
);
```

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

> **Note**
>
> The Row Resizer feature does not work when columns are configured with [Auto Row Height](https://www.ag-grid.com/react-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/react-data-grid/csv-export/) or [Excel Export](https://www.ag-grid.com/react-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.

```jsx
const rowNumbers = true;
const cellSelection = useMemo(() => { 
	return {
        enableHeaderHighlight: true,
        handle: { mode: 'fill' },
    };
}, []);
const defaultCsvExportParams = useMemo(() => { 
	return {
        exportRowNumbers: true,
    };
}, []);
const defaultExcelExportParams = useMemo(() => { 
	return {
        exportRowNumbers: true,
    };
}, []);

<AgGridReact
    rowNumbers={rowNumbers}
    cellSelection={cellSelection}
    defaultCsvExportParams={defaultCsvExportParams}
    defaultExcelExportParams={defaultExcelExportParams}
/>
```

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

```tsx
"use client";

import React, {
  useCallback,
  useMemo,
  useRef,
  useState,
  StrictMode,
} from "react";
import { createRoot } from "react-dom/client";
import { AgGridReact, AgGridProvider } from "ag-grid-react";
import {
  CellSelectionOptions,
  ClientSideRowModelModule,
  ColDef,
  ColGroupDef,
  CsvExportModule,
  CsvExportParams,
  ExcelExportParams,
  GridApi,
  GridOptions,
  ModuleRegistry,
  RowNumbersOptions,
  enableDevValidations,
} from "ag-grid-community";
import {
  CellSelectionModule,
  ContextMenuModule,
  ExcelExportModule,
  RowNumbersModule,
} from "ag-grid-enterprise";
import { IOlympicData } from "./interfaces";
import { useFetchJson } from "./useFetchJson";

if (process.env.NODE_ENV !== "production") {
  enableDevValidations();
}

const modules = [
  ClientSideRowModelModule,
  RowNumbersModule,
  CellSelectionModule,
  ExcelExportModule,
  CsvExportModule,
  ContextMenuModule,
];

const GridExample = () => {
  const containerStyle = useMemo(() => ({ width: "100%", height: "100%" }), []);
  const gridStyle = useMemo(() => ({ height: "100%", width: "100%" }), []);

  const [columnDefs, setColumnDefs] = useState<ColDef[]>([
    { field: "athlete" },
    { field: "country" },
    { field: "sport" },
    { field: "year" },
    { field: "gold" },
    { field: "silver" },
    { field: "bronze" },
  ]);
  const defaultColDef = useMemo<ColDef>(() => {
    return {
      flex: 1,
      minWidth: 100,
    };
  }, []);
  const defaultCsvExportParams = useMemo<CsvExportParams>(() => {
    return {
      exportRowNumbers: true,
    };
  }, []);
  const defaultExcelExportParams = useMemo<ExcelExportParams>(() => {
    return {
      exportRowNumbers: true,
    };
  }, []);
  const cellSelection = useMemo<boolean | CellSelectionOptions>(() => {
    return {
      enableHeaderHighlight: true,
      handle: {
        mode: "fill",
      },
    };
  }, []);

  const { data, loading } = useFetchJson<IOlympicData>(
    "https://www.ag-grid.com/example-assets/olympic-winners.json",
  );

  return (
    <AgGridProvider modules={modules}>
      <div style={containerStyle}>
        <div style={gridStyle}>
          <AgGridReact<IOlympicData>
            rowData={data}
            loading={loading}
            columnDefs={columnDefs}
            defaultColDef={defaultColDef}
            rowNumbers={true}
            defaultCsvExportParams={defaultCsvExportParams}
            defaultExcelExportParams={defaultExcelExportParams}
            cellSelection={cellSelection}
          />
        </div>
      </div>
    </AgGridProvider>
  );
};

const root = createRoot(document.getElementById("root")!);
root.render(
  <StrictMode>
    <GridExample />
  </StrictMode>,
);
```

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

## 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/react-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/react-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/react-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/react-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. |
