Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

306
Views
How can I implement the server side pagination of mui-datatable?

How can I implement the server side pagination of mui-datatable?

Problems:

  • I can't seem to retrieve whatever value was selected by the user in the rowsPerPage options. If the user clicks 15, then these rowsPerPage inside the useEffect should be updated as well:

    const getUsers = async () => {
       const usersRef = collection(db, "users");
       const q = query(
         usersRef,
         orderBy("firstName", "asc"),
         limit(rowsPerPage)
       );
       const querySnapshot = await getDocs(q);
       const arr = [];
       querySnapshot.forEach((doc) => {
         arr.push({
           ...doc.data()
         });
       });
       if (isMounted) {
         setUsers(arr);
         setCount(arr.length);
         loading(true);
       }
     };
    
  • How does the server side pagination and filter works for mui-datatable?

Recreated codesandbox: https://codesandbox.io/s/mui-datatable-server-side-pagination-filtering-and-sorting-y8pyp7?file=/src/App.js:611-1091

about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

It's pretty obvious that in the sandbox in your code you have state

const [rowsPerPage, setRowsPerPage] = useState(10);

and the IDE underlines setRowsPerPage showing you that it's never used, so even if the user changes the value the state is not updated.

The docs show there's onChangeRowsPerPage which you can pass a callback to in order to update the state and then use the state's value to send to the backend

about 4 years ago · Juan Pablo Isaza Report

0

I found examples from (it's from official examples): click here

it has good example how to handle pagination

the logic is:

you should have pageSize state that handle pageSize

onPageSize change update pageSize state

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!