React Data GridRow Numbers

Enterprise

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.

rowNumbersCopy Link
boolean | RowNumbersOptions
default: false
Configure the Row Numbers Feature.
const rowNumbers = true;

<AgGridReact rowNumbers={rowNumbers} />

Cell Selection Copy Link

When the grid is configured with Cell Selection, clicking a Row Number will select all the currently visible cells in the row.

const rowNumbers = true;
const cellSelection = true;

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

Suppressing Integration Copy Link

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.

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

<AgGridReact
    rowNumbers={rowNumbers}
    cellSelection={cellSelection}
/>
suppressCellSelectionIntegrationCopy Link
boolean
default: false
Set to true to prevent selecting all the currently visible cells in the row when clicking a Row Number.

Row Resizing Copy Link

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

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

<AgGridReact rowNumbers={rowNumbers} />
enableRowResizerCopy Link
boolean
default: false
Set to true to add a resizer to each Row Number cell that allows row resizing.

The Row Resizer feature does not work when columns are configured with Auto Row Height.

Value Export Copy Link

By default, when working with exporters such as CSV Export or 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.

const rowNumbers = true;
const cellSelection = true;
const defaultExcelExportParams = useMemo(() => { 
	return {
        exportRowNumbers: true,
    };
}, []);

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

ExportParams Copy Link

exportRowNumbersCopy Link
boolean
Set to true to allow the contents of the Header Row Column to be exported.

Customising Row Numbers Copy Link

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

suppressCellSelectionIntegrationCopy Link
boolean
default: false
Set to true to prevent selecting all the currently visible cells in the row when clicking a Row Number.
enableRowResizerCopy Link
boolean
default: false
Set to true to add a resizer to each Row Number cell that allows row resizing.
minWidthCopy Link
number
default: 60
The minimum width for the row number column.
number
default: 60
The default width for the row number column.
resizableCopy Link
boolean
default: false
Whether this column is resizable.
contextMenuItemsCopy Link
(DefaultMenuItem | MenuItemDef)[] | GetContextMenuItems
Customise the list of menu items available in the context menu. @agModule ContextMenuModule
contextCopy Link
any
Context property that can be used to associate arbitrary application data with this column definition.
onCellClickedCopy Link
Function
Callback called when a cell is clicked.
onCellContextMenuCopy Link
Function
Callback called when a cell is right clicked.
onCellDoubleClickedCopy Link
Function
Callback called when a cell is double clicked.
headerTooltipCopy Link
string
Tooltip for the column header @agModule TooltipModule
headerStyleCopy Link
HeaderStyle | HeaderStyleFunc
An object of CSS values / or function returning an object of CSS values for a particular header.
headerComponentCopy Link
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 for framework specific implementation detail.
headerComponentParamsCopy Link
any
The parameters to be passed to the headerComponent.
suppressHeaderKeyboardEventCopy Link
Function
Suppress the grid taking action for the relevant keyboard event when a header is focused.
tooltipFieldCopy Link
ColDefField
The field of the tooltip to apply to the cell. @agModule TooltipModule
tooltipValueGetterCopy Link
Function
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. @agModule TooltipModule
tooltipComponentCopy Link
any
Provide your own tooltip component for the column. See Tooltip Component for framework specific implementation details. @agModule TooltipModule
tooltipComponentParamsCopy Link
any
The params used to configure tooltipComponent. @agModule TooltipModule
valueGetterCopy Link
string | ValueGetterFunc
Function or expression. Gets the value from your data for display.
valueFormatterCopy Link
string | ValueFormatterFunc
A function or expression to format a value, should return a string.
maxWidthCopy Link
number
Maximum width in pixels for the cell.