Mottie / tablesorter

Github fork of Christian Bach's tablesorter plugin + awesomeness ~
https://mottie.github.io/tablesorter/docs/
2.61k stars 754 forks source link

Initial size of page is half of intended size #700

Closed aruballo closed 9 years ago

aruballo commented 10 years ago

Hello,

I am using the pager plugin with your tablesorter (tablesorter works great!). I have set the size to 10; however only 5 initial rows ever show up. If I continue on paging, only 5 rows continue showing up. However, once I hit one of the columns to sort the page, the table shows the correct page size. If I click the paging arrows afterwards, they also show the correct page size. So in other words, my table only seems to show half the intended page size, until a column is clicked for sorting. At which point, the page sizes stay the correct size. I tested this by changing the sizes; 20 shows 10, 30 shows 15, etc.

the table i am using follows the exact format from the examples, my call to the plugin and sorter is as follows:

$("#transTable").tablesorter().tablesorterPager({container: $("#pager"), size: 10});

Thanks!

Mottie commented 10 years ago

Hi @aruballo!

I've never seen the issue you're describing where half of the set number of pages are displayed.

I set up this demo which uses the latest master branch pager code and I started to run into problems with initial size always starting at 10; but it was working fine locally.

Then I realized the issue I was having was due to this HTML:

<select class="pagesize" title="Select page size"> 
    <option selected="selected" value="10">10</option> 
    <option value="20">20</option> 
    <option value="30">30</option> 
    <option value="40">40</option> 
</select>  

The selected="selected" option attribute was not being over-ridden by setting the select value. So I ended up adding a bit of code to the pager plugin/widget to remove the selected attribute. And I removed the selected attribute from the demo I shared.

Anyway, none of the above addresses the issue you describe. So if you could make sure you're using the latest version of the pager. If that isn't the problem, then please modify the demo I shared above to duplicate the problems you are having with the pager setting half the set number of pages, it would help me troubleshoot the problem.

aruballo commented 10 years ago

Thanks for the quick response. Ill double check and make sure I have the latest version of the pager and sorter tonight and get back with you.

Appreciate it!

On Thu, Jul 31, 2014 at 5:39 AM, Rob G notifications@github.com wrote:

Hi @aruballo https://github.com/aruballo!

I've never seen the issue you're describing where half of the set number of pages are displayed.

I set up this demo http://jsfiddle.net/Mottie/4mVfu/3234/ which uses the latest master branch pager code and I started to run into problems with initial size always starting at 10; but it was working fine locally.

Then I realized the issue I was having was due to this HTML:

The selected="selected" option attribute was not being over-ridden by setting the select value. So I ended up adding a bit of code to the pager plugin/widget to remove the selected attribute. And I removed the selected attribute from the demo I shared.

Anyway, none of the above addresses the issue you describe. So if you could make sure you're using the latest version of the pager. If that isn't the problem, then please modify the demo I shared above to duplicate the problems you are having with the pager setting half the set number of pages, it would help me troubleshoot the problem.

— Reply to this email directly or view it on GitHub https://github.com/Mottie/tablesorter/issues/700#issuecomment-50752386.

Mottie commented 10 years ago

This change is now available in the master branch in version 2.17.6.

aruballo commented 10 years ago

Hello Rob,

The newest version did not change my original issue. I was able to recreate the issue by bringing in my table, however. So it would seem the issue is probably related to how I have formed my table.

See here.

http://jsfiddle.net/Mottie/4mVfu/3234/

On Fri, Aug 1, 2014 at 7:37 PM, Rob G notifications@github.com wrote:

This change is now available in the master branch in version 2.17.6.

— Reply to this email directly or view it on GitHub https://github.com/Mottie/tablesorter/issues/700#issuecomment-50951777.

TheSin- commented 10 years ago

could you share the entire code per chance?

TS http://www.southofheaven.org/ Life begins and ends with chaos, live between the chaos!

On Aug 5, 2014, at 10:45 PM, aruballo notifications@github.com wrote:

Hello Rob,

The newest version did not change my original issue. I was able to recreate the issue by bringing in my table, however. So it would seem the issue is probably related to how I have formed my table.

See here.

http://jsfiddle.net/Mottie/4mVfu/3234/

On Fri, Aug 1, 2014 at 7:37 PM, Rob G notifications@github.com wrote:

This change is now available in the master branch in version 2.17.6.

— Reply to this email directly or view it on GitHub https://github.com/Mottie/tablesorter/issues/700#issuecomment-50951777.

— Reply to this email directly or view it on GitHub.

aruballo commented 10 years ago

You can find the relevant files here:

https://www.dropbox.com/sh/pw7j3kont3tl8bi/AAAjI_VN23wD2et8N-oC-sRfa

Basically, theres a button that calls a function in listTrans.js that calls listTrans.php. The php file generates the table. Once the table is generated I call the following on the table:

$("#transTable").tablesorter().tablesorterPager({container: $("#pager")});

Mottie commented 10 years ago

Could you please check if this problem still exists in the latest version. Thanks!

aruballo commented 9 years ago

Hello Rob,

I got a chance to try this just now but to no avail. I still have the same error.

Thanks!

On Sun, Oct 26, 2014 at 5:28 PM, Rob G notifications@github.com wrote:

Could you please check if this problem still exists in the latest version. Thanks!

— Reply to this email directly or view it on GitHub https://github.com/Mottie/tablesorter/issues/700#issuecomment-60539256.

aruballo commented 9 years ago

Rob,

I stepped through the code and found the lines that are causing this to occur, although I cant tell why. This is under the hiderows function starting at line 323 in jquery.tablesorter.pager.js:

for ( i = 0; i < l; i++ ){
    if ( !rows[i].className.match(f) ) {
        if (j === s && rows[i].className.match(c.cssChildRow)) {
            // hide child rows @ start of pager (if already visible)
            rows[i].style.display = 'none';
        } else {
            rows[i].style.display = ( j >= s && j < e ) ? '' : 'none';
            // don't count child rows
            j += rows[i].className.match(c.cssChildRow + '|' +
            c.selectorRemove.slice(1)) && !p.countChildRows ? 0 : 1;
            if ( j === e && rows[i].style.display !== 'none' &&
            rows[i].className.match(ts.css.cssHasChild) ) {
                lastIndex = i;
            }
        }
    }
}

Specifically this line:

rows[i].style.display = ( j >= s && j < e ) ? '' : 'none';

For some reason, on the initial loading of my grid using paging, this is evaluating to false and hiding half of the intended rows.

On Sat, Nov 8, 2014 at 8:42 PM, Tony Ru x4tr56x@gmail.com wrote:

Hello Rob,

I got a chance to try this just now but to no avail. I still have the same error.

Thanks!

On Sun, Oct 26, 2014 at 5:28 PM, Rob G notifications@github.com wrote:

Could you please check if this problem still exists in the latest version. Thanks!

— Reply to this email directly or view it on GitHub https://github.com/Mottie/tablesorter/issues/700#issuecomment-60539256.

Mottie commented 9 years ago

Is this issue resolved? I still can't duplicate the problem reported here... is there a way you can provide a demo?

Maybe you can use this demo to duplicate it? This demo uses filltext.com to use json to populate the table, so it isn't possible to sort or filter.

Mottie commented 9 years ago

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 the discussion in this thread.