Hafiz Temuri
Hafiz Temuri

Reputation: 4122

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

Upvotes: 4

Views: 3363

Answers (1)

Hafiz Temuri
Hafiz Temuri

Reputation: 4122

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.

Upvotes: 9

Related Questions