Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Material UI - Table Pagination is zero-based index, how to make it non-zero

Material UI Table pagination is zero-indexed, which means if I am on page 1, it will go back to page 0. How can I enforce to stop at page 1?

enter image description here

I try passing something like this, page={pageNumber || 1}, but it still calls onChangePage. Even though it does not try to load Page 0, but still its bad User Experience. You expect the previous button to be disabled in the below screenshot,

enter image description here

https://material-ui.com/api/table-pagination/#tablepagination-api

like image 668
Hafiz Temuri Avatar asked Oct 29 '25 09:10

Hafiz Temuri


1 Answers

I don't know if I have the best solution, but I make it work, by subtracting -1 when feeding to page={pageNumber - 1}, and add +1 when onChangePage = (e, pageNumber) => {..pageNumber + 1} is called.

like image 56
Hafiz Temuri Avatar answered Nov 01 '25 00:11

Hafiz Temuri



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!