# Row indices and data IDs

Row numbers help users read display order, while order IDs identify business data. Decide whether numbers stay attached to rows after sorting or are reassigned to the current display order.

Canonical: https://grid.syidax.com/docs/features/row-numbers/

<a id="understand"></a>

## How it works and when to use it

Do not invent a rowNumbers switch. Build suitable numbering through your data or a custom column. The API argument rowIndex also differs from a business ID.

In the code, grid is the Grid element prepared in the installation chapter. Check each example's data and settings, and implement the app functions and server endpoints for your project.

- [Installation and integration · Shared sample data](https://grid.syidax.com/docs/guides/getting-started.md)

<a id="example-1"></a>

## Example 1. Display arrival order

Add sequence numbers to the data to record the received order.

```javascript
grid.rowData = grid.rowData.map((row, index) => ({ ...row, receivedNo: index + 1 }));
grid.columnDefs = [{ field: 'receivedNo', headerName: 'Arrival order', editable: false }, ...grid.columnDefs];
```

Verify the result: Arrival numbers remain attached to the same orders after sorting. They do not indicate the current displayed row position.

<a id="example-2"></a>

## Example 2. Query by row position

The API for reading the first displayed row accepts a zero-based index.

```javascript
console.log(await grid.getDisplayedRowAtIndex(0));
```

Verify the result: Read the row object at the displayed position. It may differ from the first item in the original unsorted array.

<a id="example-3"></a>

## Example 3. Numbering across pages

With 20 rows per page, decide whether the next page starts at 21 or 1. Server paging also requires position information within the complete result.

Verify the result: Use headings such as Display position or Arrival order so users do not mistake a sequence number for an order identifier.

<a id="pitfalls"></a>

## Combining features and troubleshooting

Using sequence numbers as getRowId can destabilize an order's identity after insertion, deletion, or sorting. Retain the server's order ID separately.

Decide whether group headers and detail rows count toward numbering. Source order counts may differ from rendered row counts.

<a id="related-api"></a>

## APIs used by this feature

Review the shared settings together with the related documentation below.

- [Grid properties](https://grid.syidax.com/docs/options.md)
- [Column settings](https://grid.syidax.com/docs/columns.md)
- [Methods](https://grid.syidax.com/docs/methods.md)

<a id="next"></a>

## Related reading

- [How rows, columns, and IDs relate](https://grid.syidax.com/docs/guides/concepts.md)
- [Connect results and events](https://grid.syidax.com/docs/guides/data-event-access.md)
