question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Pagination Support for Table Component

See original GitHub issue

It would be awesome to add a prop to automatically manage pagination support. Something like

<Table
  {...otherProps}
  pagination
  paginationMaxRowsPerPage={20}
/>

Are there any plans to add this? Or is there any reason why there are only style examples rather than including functionality?

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Reactions:4
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

6reactions
calvinwhitehurstcommented, Jun 6, 2018

The following jquery is something I have used several times to make the SUI table pagination work. It does not however include the chevron icons. Declare the id of your table as “data” and plug this script in at the bottom of your page where the table is displayed.

$(document).ready(function(){
    $('#data').after('<div class="ui right floated pagination menu"></div>');
    var rowsShown = 10;
    var rowsTotal = $('#data tbody tr').length;
    var numPages = rowsTotal/rowsShown;
    for(i = 0;i < numPages;i++) {
        var pageNum = i + 1;
        $('.ui.right.floated.pagination.menu').append('<a href="#/" class="item" rel="'+i+'">'+pageNum+'</a> ');
    }
    $('#data tbody tr').hide();
    $('#data tbody tr').slice(0, rowsShown).show();
    $('.ui.right.floated.pagination.menu a:first').addClass('active');
    $('.ui.right.floated.pagination.menu a').bind('click', function(){

        $('.ui.right.floated.pagination.menu a').removeClass('active');
        $(this).addClass('active');
        var currPage = $(this).attr('rel');
        var startItem = currPage * rowsShown;
        var endItem = startItem + rowsShown;
        $('#data tbody tr').css('opacity','0.0').hide().slice(startItem, endItem).
        css('display','table-row').animate({opacity:1}, 300);
    });
});
1reaction
mishabermancommented, Jun 22, 2018

Nice script Calvin!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Bootstrap 4 table pagination - examples & tutorial.
Table pagination is a simple navigation which lets you split a huge amount of content within the tables into smaller parts.
Read more >
Implementing React table pagination handling one million ...
Here, we will see how to solve it using react table pagination on the server-side to handle one ... Here's a simple react...
Read more >
How to Create a Table with Pagination in React
First we'll import the useState() hook, then we'll import the hook we created and also our footer. Our table component will receive two ......
Read more >
React Table Pagination Example | TanStack Table Docs
An example showing how to implement Pagination in React Table.
Read more >
Building Table Sorting and Pagination in a Web Component
Building a web component to abstract loading data into a table and adding sorting and pagination.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found