-
Notifications
You must be signed in to change notification settings - Fork 753
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
pager not working with multiple tables in page. Only 1st 10 item visible #478
Comments
Hi @eyeris! I think the issue here is that For the first table, name it something like <table class="table1">...<table>
<div class="pager1">...</div> For the each table & pager combo after the first, change the number of the selectors: <table class="table2">...<table>
<div class="pager2">...</div> then each table will need to be initialized separately: $(".table1").tablesorter().tablesorterPager({ container: '.pager1' });
$(".table2").tablesorter().tablesorterPager({ container: '.pager2' }); |
I'm guessing this issue has been resolved, so I'm going to close it. If you continue to have problems, please feel free to continue this discussion. |
Hi, I was struck in the same issue, and I'm concerned about tons of tables on my application. So I made this simple code that gives IDs to tables, numbered as they appear in the code, and apply the specific pager to each of them. $(".tablesorter table").each(function(pageTableCount){
// Check if pageTableCount was initialized, and add 1 to its value
pageTableCount !==null ? pageTableCount++ : 1;
// Get the table and add ID with counter
table = $(this);
table.attr("id","table-sorter-"+pageTableCount);
// Does the same with the pager
pager = table.parent().find(".tablesorter-pager");
pager.attr("id","table-sorter-pager-"+pageTableCount);
// Initiate the tablesorter
table.tablesorter()
.tablesorterPager({
container: "#table-sorter-pager-"+pageTableCount
});
}) |
Please check the live demo . Using tablesorter plugin you can add multiple tables in one page. |
@pearlbells Most of the code won't work with this forked version of tablesorter, but most of it would only require a simple change (for the both the pager Addon and the widget). addPageListIn your version, it doesn't include filtered rows (using the filtered widget): function addPageList(table) {
var i, len,
c = table.config,
p = c.pager;
p.filteredRows = 0;
normalized = c.cache[ 0 ].normalized;
len = normalized.length;
for ( i = 0; i < len; i++ ) {
p.filteredRows += p.regexRows.test( normalized[ indx ][ c.columns ].$row[ 0 ].className ) ? 0 : 1;
}
p.filteredPages = Math.ceil( p.filteredRows / p.size );
p.totalPages = Math.ceil(p.totalRows / p.size);
p.$container.find('ul').empty();
for (i = 1; i <= c.filteredPages; i++) {
p.$container.find('ul').append('<li>' + i + '</li>');
}
} setPageIn my forked version, you have access to these methods: $('table').trigger( method, [ value(s) ] );
addClassIn my forked version, use function addClass(table){
var p = table.config.pager;
p.$container.find('li').removeClass('active');
p.$container.find('li').eq(p.page).addClass('active');
} click Eventtable.config.pager.$goto.on( 'click', 'li', function() {
var pageNum = parseInt( $(this).html(), 10 ) - 1;
$(table).trigger('pageSet', pageNum);
return false;
}); |
Hi , thanks for the reply. I have used the tablesorter plugin to add sorting and pagination to one of my wordpress plugins. I am not sure which version i have used. but my needs includes : For that i have added the function that listed in my blog to meet my needs that seems working. anyway thank you very much the reply. Pearl |
Hi, I have the same problem with the last version of tablesorter 2.31.1 |
Hi @SqualaDesign! Please make sure to initialize each pager separately - refer to this example in the comments above. |
I don't have different pager and also no of them has IDs |
Please share the code being used so we can help troubleshoot the problem. |
Hi I am using table sorter with bootstrap3
everything is ok when there is only one table in page
like
$("table").tablesorter({......
But when there are several tables with
<table>
in page. the pager doesnt work. the arrows are disabled and its strange that only the first 10 items are visible. No arrows are working.I tried everything so far but failed. Can anyone help.
The text was updated successfully, but these errors were encountered: