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] Setting starting page not working? #1085

Closed
a-mair opened this issue Nov 17, 2015 · 8 comments
Closed

[Pager] Setting starting page not working? #1085

a-mair opened this issue Nov 17, 2015 · 8 comments

Comments

@a-mair
Copy link
Contributor

a-mair commented Nov 17, 2015

Hi,

I try to use the "page" option for the tablesorterpager addon but it doesn't work. No matter how much content the table has, always page 0 will be shown, e.g.: {..., page: 2, savePages: false, ...}

Is this a known issue?

Best regards,
Andreas

@Mottie
Copy link
Owner

Mottie commented Nov 17, 2015

Hi @a-mair!

I've never heard of that being an issue. I could help troubleshoot the problem if you would please share some code.

@a-mair
Copy link
Contributor Author

a-mair commented Nov 18, 2015

Hi Mottie,

I've simply taken http://mottie.github.io/tablesorter/docs/example-pager.html and modified the "pagerOptions" to read "page: 2, savePages: false".

Regards,
Andreas

@Mottie
Copy link
Owner

Mottie commented Nov 18, 2015

Hi @a-mair!

That appears to be a bug 😿 .... if you look at the console, you'll see it's trying to set the page to -1 LOL. I'll sort it out and get that fixed ASAP.

@a-mair
Copy link
Contributor Author

a-mair commented Nov 19, 2015

Hi @Mottie,

thanks for the quick fix!
There's another thing that's not working as expected:
If one sets "page" to a higher number than pages exist, then the last page isn't shown but the first page.

Regards,
Andreas

@Mottie
Copy link
Owner

Mottie commented Nov 19, 2015

Ok, that should now be fixed in the master branch.

@a-mair
Copy link
Contributor Author

a-mair commented Nov 20, 2015

Hi @Mottie,

No, it still doesn't work.

For debugging I modified the example-pager.html to initialize the tablesorter like this:

.tablesorter({
    theme: 'blue',
    widthFixed: true,
    widgets: ['zebra', 'filter']   // Added 'filter'
})

I modified the "pagerOptions" to read "page: 2, savePages: false" and in jquery.tablesorter.pager.js I changed "getTotalPages" like this:

getTotalPages = function( table, p ) {
    console.log("getTotalPages: p.page=" + p.page + " ts.hasWidget( table, 'filter' )=" + ts.hasWidget( table, 'filter' ) + " p.totalPages=" + p.totalPages + " p.filteredPages=" + p.filteredPages);
    return ts.hasWidget( table, 'filter' ) ? Math.min( p.totalPages, p.filteredPages ) : p.totalPages;
},   

Now I get the following console log in FireBug:

Pager: Initializing
getTotalPages: p.page=2 ts.hasWidget( table, 'filter' )=true p.totalPages=0 p.filteredPages=0
Rebuilt table ( 7ms )
getTotalPages: p.page=2 ts.hasWidget( table, 'filter' )=true p.totalPages=5 p.filteredPages=0
Pager: Changing to page -1

There has been no filtering done yet, well actually there's no filter text set yet. In that state there's no "" where one can enter filter text.

Regards,
Andreas

@Mottie
Copy link
Owner

Mottie commented Nov 20, 2015

Ok, that should finally fix the problem crosses fingers.

@a-mair
Copy link
Contributor Author

a-mair commented Nov 23, 2015

@Mottie
Yes, that's fixed now, but there's another thing:
I need to initially display the last page. AFAIK there's no special value for the "page" setting (like for example "-1") to get this. I try to avoid an extra "" counting so I use "99999".

This doesn't work if I set this in "pagerOptions", but it works if I trigger "pageSet".
I'd expect equal results.
What about defining a special value for the last page? Maybe "-1"? If someone will ever need this could also be extended to let negative numbers start counting from the last page...

Regards,
Andreas

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