Hide pagination if rows <= rows per page
This commit is contained in:
1 parent
064e75f862
commit
ecdbbac684
1 file changed
+32
-26
@@ -90,6 +90,36 @@ const BasicTable = ({ data, paginated, reversed }) => {
|
|||||||
return <div>No data</div>;
|
return <div>No data</div>;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let paginationComponent = <></>;
|
||||||
|
if (paginated === true && displayData.length > rowsPerPage) {
|
||||||
|
paginationComponent = (
|
||||||
|
<Pagination
|
||||||
|
count={Math.ceil(data.rows.length / rowsPerPage)}
|
||||||
|
page={page + 1}
|
||||||
|
onChange={(event, value) => handleChangePage(event, value - 1)}
|
||||||
|
shape="rounded"
|
||||||
|
renderItem={(item) => (
|
||||||
|
<PaginationItem
|
||||||
|
slots={{
|
||||||
|
previous: ArrowBackRoundedIcon,
|
||||||
|
next: ArrowForwardRoundedIcon,
|
||||||
|
}}
|
||||||
|
{...item}
|
||||||
|
sx={{
|
||||||
|
"&:focus": {
|
||||||
|
outline: "none",
|
||||||
|
},
|
||||||
|
"& .MuiTouchRipple-root": {
|
||||||
|
pointerEvents: "none",
|
||||||
|
display: "none",
|
||||||
|
},
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<TableContainer component={Paper}>
|
<TableContainer component={Paper}>
|
||||||
@@ -118,32 +148,8 @@ const BasicTable = ({ data, paginated, reversed }) => {
|
|||||||
</TableBody>
|
</TableBody>
|
||||||
</Table>
|
</Table>
|
||||||
</TableContainer>
|
</TableContainer>
|
||||||
{paginated === true && (
|
|
||||||
<Pagination
|
{paginationComponent}
|
||||||
count={Math.ceil(data.rows.length / rowsPerPage)}
|
|
||||||
page={page + 1}
|
|
||||||
onChange={(event, value) => handleChangePage(event, value - 1)}
|
|
||||||
shape="rounded"
|
|
||||||
renderItem={(item) => (
|
|
||||||
<PaginationItem
|
|
||||||
slots={{
|
|
||||||
previous: ArrowBackRoundedIcon,
|
|
||||||
next: ArrowForwardRoundedIcon,
|
|
||||||
}}
|
|
||||||
{...item}
|
|
||||||
sx={{
|
|
||||||
"&:focus": {
|
|
||||||
outline: "none",
|
|
||||||
},
|
|
||||||
"& .MuiTouchRipple-root": {
|
|
||||||
pointerEvents: "none",
|
|
||||||
display: "none",
|
|
||||||
},
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
)}
|
|
||||||
/>
|
|
||||||
)}
|
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in new issue
Block a user