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

269
Vistas
Gridjs pagination and sort with server side parameters

i use gridsjs sort and paginaton server side config, when i use for pagination its work perfectly, but for sorting the params not work properly like this http://scrum.test/api/customers&sort_by=id&sort=DESC?page=1 when the correct one like this http://scrum.test/api/customers/?sort_by=id&sort=ASC&page=1, and this is my code.

let tableCustomer = $('#table-customer').Grid({
        columns: [
            'ID',
            'Name',
            'Email'
        ],
        search: true,
        pagination: {
            enabled: true,
            limit: 20,
            server: {
                url: (prev, page, limit) =>  {
                    return `${prev}?page=${(page+1)}`
                }
            }
        },
        sort : {
            server: {
                url: (prev, columns) => {
                    console.log('sprt', prev);
                    if (!columns.length) return prev;
                    const col = columns[0];
                    const dir = col.direction === 1 ? 'ASC' : 'DESC';
                    let colName = ['id', 'name', 'email'][col.index];
                    
                    return `${prev}&sort_by=${colName}&sort=${dir}`;
                }
            }
        },
        
        server : {
            url: BASE_URL + 'api/customers',
            then: response => response.data.map(customer => [ customer.id, customer.name, customer.email]),
            total: response => response.total
        },
        
        
    });

about 4 years ago · Juan Pablo Isaza
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