Manual Pagination doesn't update `table.getRowModel().rows` - it shows all results
Describe the bug
I was looking at the manual pagination example here:
https://tanstack.com/table/v8/docs/examples/react/pagination-controlled and noticed that the pagination is happening at the query level.
When trying to add the pagination client side, the logic seems to work properly, but the content doesn't update based on the new pagination values. A reproducible example is here:
https://codesandbox.io/p/sandbox/boring-wilbur-fqkd7r?embed=1&file=%2Fsrc%2Fmain.tsx%3A79%2C37-82%2C6
My default pagination object looks like this:
{
pageIndex: 0,
pageSize: 10
}
but the table shows 100 results. if I change the visible rows from the dropdown in the UI or change the page, the table always shows the whole payload vs paginated results.
Am I actually supposed to slice the data myself off table.getRowModel().rows?
Your minimal, reproducible example
https://codesandbox.io/p/sandbox/boring-wilbur-fqkd7r?embed=1&file=%2Fsrc%2Fmain.tsx%3A79%2C37-82%2C6
Steps to reproduce
Just load the UI and see the data is not being paginated
Expected behavior
Table should only show 10 items as per the default object
How often does this bug happen?
Every time
Screenshots or Videos
No response
Platform
whatever codesandbox is running on
react-table version
v8.9.2
TypeScript version
No response
Additional context
No response
Terms & Code of Conduct
- [X] I agree to follow this project's Code of Conduct
- [X] I understand that if my bug cannot be reliable reproduced in a debuggable environment, it will probably not be fixed and this issue may even be closed.
Same here.
@luciodale If you are using controlled pagination you should send only the slice of the data you want to display. So if you have pageSize: 10 table is expecting you to send only 10 items into data property.
I agree with @ajkl2533, the issue should be closed.
just set manualPagination: true, in your useReactTable for server and manual pagination:
const table = useReactTable({
data,
columns,
state: {
sorting,
columnVisibility,
rowSelection,
columnFilters,
},
manualPagination: true,
enableRowSelection: true,
onRowSelectionChange: setRowSelection,
onSortingChange: setSorting,
onColumnFiltersChange: setColumnFilters,
onColumnVisibilityChange: setColumnVisibility,
getCoreRowModel: getCoreRowModel(),
getFilteredRowModel: getFilteredRowModel(),
getPaginationRowModel: getPaginationRowModel(),
getSortedRowModel: getSortedRowModel(),
getFacetedRowModel: getFacetedRowModel(),
getFacetedUniqueValues: getFacetedUniqueValues()
});