Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pagination Rows per Page resetting itself after clicking on custom button in column #2019

Open
max-chen-innosys opened this issue Aug 6, 2023 · 6 comments

Comments

@max-chen-innosys
Copy link

Hi, I'm facing an issue whereby the number of rows per page displayed is resetting itself everytime I click on a custom button I've added via options in the toolbar.

This also happens when I click on a button I added to each row.

The number of rows per page is initially 50. When I select it as 75 and click on my custom buttons, it resets to 50 per page.

@Usama-Tahir
Copy link
Contributor

@max-chen-innosys can you provide a repro example? I will try to look into this issue.

@LouGitta
Copy link

LouGitta commented Jul 1, 2024

Hi, same issue as @max-chen-innosys but not with the toolbar.

So here is my default table with 50 rows per page when it load
image

I can set it to 10 rows no problem with it
image

But when i click on my right side wrench button instantly it goes to 50 rows
image

I have the same issue with checkbox in the toolbarselect

If you need anything more i'm here
Thanks

@janlew
Copy link

janlew commented Jul 3, 2024

Have the same issue

@LouGitta
Copy link

LouGitta commented Jul 3, 2024

Have the same issue

@janlew I think my team found a solution that work

So i've add in my MuiDataTable.js

  const [rowsPerPage, setRowsPerPage] = React.useState(50);
  const [page, setPage] = React.useState(0);

and i add this after all my options still in the table.js

    rowsPerPage: rowsPerPage,
    rowsPerPageOptions: [10, 30, 50, 100],
    page: page,
    onChangePage: (newPage) => {
      setPage(newPage);
    },
    onChangeRowsPerPage: (numberOfRows) => {
      setRowsPerPage(numberOfRows);
    },

Hope this may help you

@janlew
Copy link

janlew commented Jul 3, 2024

Have the same issue

@janlew I think my team found a solution that work

So in i've add in my MuiDataTable.js

  const [rowsPerPage, setRowsPerPage] = React.useState(50);
  const [page, setPage] = React.useState(0);

and i add this after all my options still in the table.js

    rowsPerPage: rowsPerPage,
    rowsPerPageOptions: [10, 30, 50, 100],
    page: page,
    onChangePage: (newPage) => {
      setPage(newPage);
    },
    onChangeRowsPerPage: (numberOfRows) => {
      setRowsPerPage(numberOfRows);
    },

Hope this may help you

Thanks for quick reply! I did almost the same but with localStorage :)

@LouGitta
Copy link

LouGitta commented Jul 3, 2024

Have the same issue

@janlew My team found a solution that work
So in i've add in my MuiDataTable.js

  const [rowsPerPage, setRowsPerPage] = React.useState(50);
  const [page, setPage] = React.useState(0);

and i add this after all my options still in the table.js

    rowsPerPage: rowsPerPage,
    rowsPerPageOptions: [10, 30, 50, 100],
    page: page,
    onChangePage: (newPage) => {
      setPage(newPage);
    },
    onChangeRowsPerPage: (numberOfRows) => {
      setRowsPerPage(numberOfRows);
    },

Hope this may help you

Thanks for quick reply! I did almost the same but with localStorage :)

Great! It's not sensitive data but i don't know if it's a real safe way to do it.
But if it works don't touch ;) !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants