I am getting data partially from backend (let's say 10 rows per api call) and I want to call the api on page change but I am unable to find any relevant option in react-bootstrap-table pagination. Is there any solution to this problem?
2 Answers
"react-bootstrap-table2-paginator" takes a prop of onPageChange where you can do what you want with the page number https://codesandbox.io/s/react-bootstrap-table-paging-example-forked-rqhyd5
<BootstrapTable
bootstrap4
keyField="id"
data={products}
columns={columns}
pagination={paginationFactory({ sizePerPage: 5, onPageChange:(page)=>console.log("DB CALL with page" + page) })}
/>
1 Comment
Ryan Zeelie
ps: Check the console on codesandbox link
if you dont want to see pagination selectbox , you can add sizePerPageList property in paginationFactory settings,
form example;
<BootstrapTable
bootstrap4
keyField="id"
data={products}
columns={columns}
pagination={paginationFactory({
sizePerPageList: [
{
text: "5",
value: 5
}
],
onPageChange: (page) => console.log("DB CALL with page" + page)
})}
/>