react-js-pagination icon indicating copy to clipboard operation
react-js-pagination copied to clipboard

Allow callback for rendering page numbers

Open jamesheazlewood opened this issue 6 years ago • 0 comments

For example, if I want to add an icon or add commas for thousands (1,002 1,003 etc) for large page numbers.

<Pagination
   prevPageText="Prev"
   nextPageText="Next"
   firstPageText="First"
   lastPageText="Last"

   numberText={i => commas(i)}

   innerClass="pagination"
   itemClass="page-item"
   linkClass="page-link"
   activePage={activePage}
   itemsCountPerPage={pageSize}
   totalItemsCount={totalRecords}
   onChange={pageNumber => {
      handlePageChange(pageNumber, pageSize, tableIdentifier);
   }}
/>

Potential changes:

for (
      let i = paginationInfo.first_page;
      i <= paginationInfo.last_page;
      i++
    ) {
      pages.push(
        <Page
          isActive={i === activePage}
          key={i}
          href={getPageUrl(i)}
          pageNumber={i}

          pageText={numberText ? numberText(i) : i + ""}

          onClick={onChange}
          itemClass={itemClass}
          linkClass={linkClass}
          activeClass={activeClass}
          activeLinkClass={activeLinkClass}
        />
      );
    }

jamesheazlewood avatar Jan 09 '19 06:01 jamesheazlewood