3

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

Here is an image of the options enter image description here

1 Answer 1

2

For paging you need:

  1. know the number of records.
  2. number of records displayed on page.
  3. 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}`);

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.