Skip to content

Commit

Permalink
fix: getRow with expanded row model and selection (#5253)
Browse files Browse the repository at this point in the history
  • Loading branch information
KevinVandy committed Jan 3, 2024
1 parent 89ea3ef commit ca5c187
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions packages/table-core/src/core/table.ts
Expand Up @@ -374,15 +374,20 @@ export function createTable<TData extends RowData>(
getRowModel: () => {
return table.getPaginationRowModel()
},
//in next version, we should just pass in the row model as the optional 2nd arg
getRow: (id: string, searchAll?: boolean) => {
const row = (searchAll ? table.getCoreRowModel() : table.getRowModel())
.rowsById[id]
let row = (
searchAll ? table.getPrePaginationRowModel() : table.getRowModel()
).rowsById[id]

if (!row) {
if (process.env.NODE_ENV !== 'production') {
throw new Error(`getRow expected an ID, but got ${id}`)
row = table.getCoreRowModel().rowsById[id]
if (!row) {
if (process.env.NODE_ENV !== 'production') {
throw new Error(`getRow could not find row with ID: ${id}`)
}
throw new Error()
}
throw new Error()
}

return row
Expand Down

0 comments on commit ca5c187

Please sign in to comment.