Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

304
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda