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

262
Views
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
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!