Skip to content

What is the difference rows and flatRows? #4924

Closed Answered by nktnet1
xkomiks asked this question in Q&A
Discussion options

You must be logged in to vote

As of v8, see https://tanstack.com/table/v8/docs/guide/row-models


Row Model Data Structure

Each row model will provide you the rows in 3 different useful formats:

  • rows - An array of rows.
  • flatRows - An array of rows, but all sub-rows are flattened into the top level.
  • rowsById - An object of rows, where each row is keyed by its id. This is useful for quickly looking up rows by their id with better performance.
console.log(table.getRowModel().rows) // array of rows
console.log(table.getRowModel().flatRows) // array of rows, but all sub-rows are flattened into the top level
console.log(table.getRowModel().rowsById['row-id']) // object of rows, where each row is keyed by its `id`

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by xkomiks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants