Skip to content
masterclassBuddyTech Buzz5 fresh blogs · 5:00 AM IST

TanStack · Type Alias

RowModel

RowModel is the processed table-row result used by TanStack Table. It provides hierarchical rows, flattened rows, and an ID-keyed row lookup.

How it works

RowModel describes the result produced by TanStack Table's row-model pipeline. It exposes the current rows, a flattened version including sub-rows, and an ID-keyed lookup object for efficient row access.

Syntax

type RowModel<TData> = {
  rows: Row<TData>[]
  flatRows: Row<TData>[]
  rowsById: Record<string, Row<TData>>
}

Returns

An object with rows, flatRows, and rowsById collections.

Key points

  • A RowModel deliberately offers three complementary views of the same processed data.
  • rows contains the row objects in their hierarchical arrangement.
  • flatRows is the convenient collection when nested rows must be handled uniformly.
  • rowsById maps identifiers to rows for direct access.
  • The ID map is intended for faster row lookup than repeatedly searching an array.
  • The final model can reflect a defined sequence of feature-specific transformations.

Common mistakes

  • For rendering, prefer the table's final getRowModel result rather than selecting an intermediate model yourself.

Example: Inspect a row model

import type { RowModel, RowData } from '@tanstack/table-core'

type Person = { name: string }

declare const model: RowModel<Person>

const visibleRows = model.rows
const allRows = model.flatRows
const byId = model.rowsById

console.log(visibleRows, allRows, byId)

Reads the three row collections exposed by a row model.

When to use it

Table rendering

Render the table's current output after enabled features process the data.

Flatten hierarchical rows

Iterate through nested data as one collection.

Fast row lookup

Retrieve a row directly when its identifier is known.

Interview questions

QWhat data does RowModel expose?

A RowModel contains rows, flatRows, and rowsById. The rows array preserves the hierarchical structure, flatRows removes nesting, and rowsById supports lookup by row ID.

Follow-up: When would flatRows be preferable? It is useful when an operation must process every nested row as one flat collection.

QHow does RowModel relate to table rendering?

The final row model is produced after the enabled row-model stages process the data. The documented pipeline can include filtering, grouping, sorting, expanding, and pagination before getRowModel returns the result.

Follow-up: Why should rendering normally use getRowModel? Because it represents the final output after the applicable feature transformations.

QWhy are three representations provided?

rowsById is an object keyed by row ID, enabling direct row retrieval without scanning the rows array. rows and flatRows serve hierarchical traversal and flattened traversal respectively.

Follow-up: What determines whether nested rows appear in flatRows? The row model's generated sub-row structure; flatRows includes those sub-rows at the top level.

  • Row
  • RowData
  • getCoreRowModel
  • getRowModel
  • createFilteredRowModel
  • createSortedRowModel
  • createGroupedRowModel
  • createExpandedRowModel

Source: Row Models Guide. Checked 2026-10-15.