Skip to content
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 resets to page one after table rebuild #565

Closed
dandanknight opened this issue Apr 1, 2014 · 3 comments
Closed

Pager resets to page one after table rebuild #565

dandanknight opened this issue Apr 1, 2014 · 3 comments

Comments

@dandanknight
Copy link

Hi Mottie,

I've just updated to 2.15.12 from 2.13, the pager plugin I was using (jquery.tablesorter.pager.js) was dated 5/27/13.

I have a table with a large number of items, an ajax call refreshes the table every few seconds, and rebuilds the entire table in the fashion...

$.ajax({
    type:'GET',
    url: 'some/url',
    success:function(data){
         var tbl_body = "";
         $.each(data, function(){
               tbl_body += makeRow(this);
          }); 
          $("#dbTable tbody").html(tbl_body);
          $("table").trigger("update");
    }
});

With the new pager plugin, after this happens, the pager goes back to page one as soon as the trigger update is executed, whereas the old pager plugin maintained the page that it was previously on.

Is this something I am doing incorrectly, has a feature changed, or is it a bug?

I am initializing my table as follows....

    $("#dbTable").tablesorter({
    theme : "blackice",
    widthFixed: false,
    cssChildRow: "tablesorter-childRow",
    headerTemplate : '{content} {icon}',
    widgets : [ "uitheme", "filter", "resizable", "saveSort", "zebra"],
    widgetOptions : {
        filter_ignoreCase : true,
        filter_reset : ".reset",
        resizable : true,
        resizable_addlastcolumn : true
    }}).tablesorterPager({
        container: $(".pager"),
        size : 10,
        cssGoto  : ".pagenum",
        savePages : true,
        removeRows: false,
        updateArrows: true,
        output: '{startRow} to {endRow} of {filteredRows} ({totalRows} total)'
    }));

I'd very much appreciate your help/input.

Thanks.

@Mottie
Copy link
Owner

Mottie commented Apr 1, 2014

Hi @dandanknight!

Hmm, back in v2.14.4 , I added some code to always reset the pager to page zero when a table is filtered (see issue #456).

For now, you can bypass this code by changing this pager event listener (ref):

$('#dbTable')
    .unbind('filterStart.pager')
    .bind('filterStart.pager', function(e, filters) {
        this.config.pager.currentFilters = filters;
    });

In the next update, I'll add a pager option to reset the page to zero if desired.

@dandanknight
Copy link
Author

Hi!
Works a treat, thanks very much.
Cheers

@Mottie
Copy link
Owner

Mottie commented Apr 21, 2014

I ended up adding a pager pageReset option which can either be set to a page number or false to disable the reset.

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants