Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: getRow with expanded row model and selection #5253

Merged
merged 1 commit into from
Jan 3, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
15 changes: 10 additions & 5 deletions packages/table-core/src/core/table.ts
Original file line number Diff line number Diff line change
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