Reputation: 493
I am using https://github.com/jbritten/jquery-tablesorter-filter , jquery table sorter plugin, and the jquery table sorter pagination.
when I load the settings in the document load and add the filter it destroys pagination. I have had this issue with every single table filter plugin I have tried to use.
var $table = $('#billing_summary_table')
.on('pagerInitialized pagerComplete', function (e, c) {
var i, pages = '', t = [],
cur = c.page + 1,
start = cur > 1 ? (c.totalPages - cur < 3 ? -3 + (c.totalPages - cur) : -1) : 0,
end = cur < 3 ? 5 - cur : 2;
for (i = start; i < end; i++) {
if (cur + i >= 1 && cur + i < c.totalPages) { t.push( cur + i ); }
}
// make sure first and last page are included in the pagination
if ($.inArray(1, t) === -1) { t.push(1); }
if ($.inArray(c.totalPages, t) === -1) { t.push(c.totalPages); }
// sort the list
t = t.sort(function(a, b){ return a - b; });
// make links and spacers
$.each(t, function(j, v){
pages += '<a href="#" class="' + (v === cur ? 'current' : '') + '">' + v + '</a>';
pages += j < t.length - 1 && ( t[j+1] - 1 !== v ) ? ' ... ' : ( j >= t.length - 1 ? '' : ' ' );
});
$('.pagecount').html(pages);
})
.tablesorter({
widgets: ['zebra']
})
.tablesorterPager({
container: $(".pager"),
size: 3,
output: 'showing: {startRow} to {endRow} ({totalRows})',
removeRows: false
})
.tablesorterFilter({
filterContainer: "#filter",
filterColumns: [0,1,2,3]
});
Upvotes: 1
Views: 3952
Reputation: 321
Try to put filter into .tablesorter()
function
.tablesorter({
widgets: ['zebra'],
filter_columnFilters: true,//If u want a single filter for each column
filter_external: '#filter'
}}
You have more info here: Tablesorter external input
I think it will work for you, I was implementing it just today.
Upvotes: 1
Reputation: 86403
I would suggest you try out my fork of tablesorter. The reason is that the pager plugin has an option removeRows
which is false
by default, so all tables rows still exist on the page (in the DOM) making filtering easy. So, it should work (untested) with the filter plugin you mentioned.
Also, check out:
Upvotes: 2