locustjs-pagination

This library provides utilities regarding paging and pagination for data grids.

Usage no npm install needed!

<script type="module">
  import locustjsPagination from 'https://cdn.skypack.dev/locustjs-pagination';
</script>

README

locustjs-pagination

This library provides utilities regarding paging and pagination for data grids.

The library contains a pagingCalc() function that helps calculating paging based on a given recordcount, pagesize and current page.

Here is an example:

import { pagingCalc } from 'locustjs-pagination';

const pageSize = 8;
const recordCount = 456;
const currentPage = 20;
const visiblePages = 6;

const paging = pagingCalc(currentPage, recordCount, pageSize, visiblePages);

console.log(paging);
/*
  result:
  {
    fromPage: 19
    fromRow: 153
    page: 20
    pageCount: 57
    pageSize: 8
    recordCount: 456
    toPage: 24
    toRow: 160
    visiblePages: 6
  }
*/