import { Content, Row, Col, Box, Button, Inputs, DataTable } from "adminlte-2-react"
...
getData() {
this.setState({ loading: true });
const waitTime = Math.random() * 2000;
setTimeout(() => {
const { order, activePage, selectedEngine } = this.state;
let localData = data;
const filteredData = localData.sort((a, b) => {
if (a[order.column].toLowerCase() < b[order.column].toLowerCase()) { return order.direction === 'asc' ? -1 : 1; }
if (a[order.column].toLowerCase() > b[order.column].toLowerCase()) { return order.direction === 'asc' ? 1 : -1; }
return 0;
}).slice(10 * activePage, 10 * activePage + 10);
const hasMore = filteredData.slice(10 * activePage, 10 * activePage + 10).length === 10;
this.setState({ filteredData, loading: false, hasMore });
}, waitTime);
}
...
<DataTable
id="external-data"
columns={firstColumns}
options={{
autoWidth: false,
select: true,
rowId: 'browser',
}}
data={filteredData}
page={activePage}
pageSize={10}
// hasMore={hasMore}
totalElements={(filteredData && localData.length) || 0}
onPageChange={(page) => {
this.setState({ activePage: page });
this.getData();
}}
/>
When we externally control data in
DataTablecomponent by passingtotalElements, we click on last page. Then button Next is disabled, but you can still click on it and go to next page, when there is no elements.hasMoredoesn't affect anything