I am using BootstrapTable from react-bootstrap-table and taking data from external API. Each time I get an object of 30 items. Therefore the pageSize is 30 but I get the totalPages variable from API which is let's say 6. Unfortunately, the table data is each time 30 so there is just one page
I would like to tell the table how many pages I want to have - 6 - and each time onClick in the pagination item I will call another API link. How can I achieve this?
onPageChange = page => {
alert(`Let's go to page: ${page}`);
};
render() {
const options = {
onPageChange: this.onPageChange,
hideSizePerPage: true,
page: 1,
sizePerPage: this.props.pageSize,
paginationSize: 6,
};
return (
<Card>
<CardHeader>
<h1> Sales report</h1>
</CardHeader>
<CardBody>
<BootstrapTable
data={this.props.sales}
version="4"
striped
hover
pagination
options={options}
keyField="Type"
>
{tableHeaders.map((header, index) => (
<TableHeaderColumn key={index} dataField={header}>
{header}
</TableHeaderColumn>
))}
</BootstrapTable>
</CardBody>
</Card>
);
}