Currently you can paginate towards the backend, with the next and previous option, but I can't do it with the rows per page option, how do I make the two options work? Thank you
1 Answer
For paging you need:
- know the number of records.
- number of records displayed on page.
- page number.
Send to server from client: number of records on page and page number)
Send to client from server: records between from, to
const count = 20; // for example we have 20 records
const size = 7; // there are 7 records on each page
// number of pages
const countPages = Math.ceil (20/7);
//show records on page 2:
const page = 2; // display 2nd page
const from = (page - 1) * size;
const to = Math.min (from + size- 1, count);
console.log(`we have ${count} records, ${size} per page` )
console.log('number of pages', countPages);
console.log(`on page ${page} records from ${from} to ${to}`);
