Skip to content

Commit ca5c187

Browse files
authoredJan 3, 2024
fix: getRow with expanded row model and selection (#5253)
1 parent 89ea3ef commit ca5c187

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed
 

‎packages/table-core/src/core/table.ts

+10-5
Original file line numberDiff line numberDiff line change
@@ -374,15 +374,20 @@ export function createTable<TData extends RowData>(
374374
getRowModel: () => {
375375
return table.getPaginationRowModel()
376376
},
377+
//in next version, we should just pass in the row model as the optional 2nd arg
377378
getRow: (id: string, searchAll?: boolean) => {
378-
const row = (searchAll ? table.getCoreRowModel() : table.getRowModel())
379-
.rowsById[id]
379+
let row = (
380+
searchAll ? table.getPrePaginationRowModel() : table.getRowModel()
381+
).rowsById[id]
380382

381383
if (!row) {
382-
if (process.env.NODE_ENV !== 'production') {
383-
throw new Error(`getRow expected an ID, but got ${id}`)
384+
row = table.getCoreRowModel().rowsById[id]
385+
if (!row) {
386+
if (process.env.NODE_ENV !== 'production') {
387+
throw new Error(`getRow could not find row with ID: ${id}`)
388+
}
389+
throw new Error()
384390
}
385-
throw new Error()
386391
}
387392

388393
return row

0 commit comments

Comments
 (0)
Please sign in to comment.