AJAX call not rendering on the screen when page number is greater than 0 #151

Closed
trevorbernard opened this Issue Oct 12, 2012 · 5 comments

3 participants

@trevorbernard

The first page renders but any subsequent pages don't. The AJAX call is correctly returning the same data. I based the code from this page: http://mottie.github.com/tablesorter/docs/example-pager-ajax.html

It also appears to be happening on that page as well.

Warmest regards

@Mottie
Owner

Wow, I totally missed that. It looks like the rows are there, just hidden, but I'll look into it. Thanks!

@trevorbernard

Awesome, thanks!

@trevorbernard

The culprit appears to be the following line:

https://github.com/Mottie/tablesorter/blob/master/addons/pager/jquery.tablesorter.pager.js#L159

I'm not quite sure what the first predicate condition is supposed to accomplish but it seems like j should be initialized at s which would always equal true. In it's current form, all rows not on the first page would be display:none. Thoughts?

@sabw8217

I worked around this by changing
https://github.com/Mottie/tablesorter/blob/master/addons/pager/jquery.tablesorter.pager.js#L156
from

j = 0;

to

j=( typeof(a.ajaxUrl) === 'string' ) ? s : 0;

YMMV, but it seems to be working for me.

@Mottie
Owner

LOL that'll work too... I actually wrapped the whole function:

hideRows = function(table, c){
    if (!c.ajaxUrl) {
        var i,
        rows = $('tr:not(.' + table.config.cssChildRow + ')', table.tBodies),
        l = rows.length,
        s = ( c.page * c.size ),
        e =  s + c.size,
        j = 0; // size counter
        for ( i = 0; i < l; i++ ){
            if (!/filtered/.test(rows[i].className)) {
                rows[i].style.display = ( j >= s && j < e ) ? '' : 'none';
                j++;
            }
        }
    }
},

I am actually working on updating the headers correctly when information is provided, then I'll push the updates.

@Mottie Mottie closed this in 597ec7d Oct 13, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment