How can I restore the current page after an operation with jQuery Tablesorter?
Asked Answered
O

2

6

I'm working with tablesorter and I've not been able to find any documentation about the plugin tablesorter pager. The thing is that I have a table that displays some data and in each row there is a delete link that has attached to it the unique identifier of the element that it's going to be deleted (obviously).

Is it possible to save the page in which I'm at the moment of deleting, and then set the pager straight to the page it was before? It is because when I reload the table after deleting the row, it goes back to the first page.

What I want to do is something like this:

//Before deleting 
var page = //Here is what I'm asking for, a way to get the page that is on now
var rowsPerPage = //A way to obtain the size option of the pager
//Delete row

//Refresh table and then a way to set the 
///page where I was again.
     $("#TST").tablesorter(...)
                 .tablesorterPager({
                     container: $("#TSTPager"),
                     positionFixed: false,
                     size: 5
                 });

Thank you very much, Victor

Oblivious answered 22/6, 2010 at 15:4 Comment(0)
O
7

If you click on the tablesorter tag, you will find several other developers wrestling with this type of problem, such as Need Help with Jquery TableSorter Pager plugin.

In an answer there, and replies to other similar questions, a suggestion is made to use DataTables.net instead.

Yes, it's frustrating to think of changing tools at this point, but the level of frustration with your paging problem, and the favorable opinions about the other tool, suggest that you might be able to get this problem solved more quickly, and get your project back on track, by changing tools.

Oribelle answered 22/6, 2010 at 15:16 Comment(0)
Y
0

This is a very old question, but for what it's worth, the Pager plug-in now has an option called savePages that saves the pagination state even on refresh.

This issue covers it: https://github.com/Mottie/tablesorter/issues/444

Yard answered 28/1, 2015 at 20:46 Comment(2)
A friendly tip, a sample code snippet will improve your answer greatly.Hemo
This particular link points to an unofficial fork of the original tablesorter library. So it's not the same library. It's hard to tell as the websites look very similar. Home page of the fork - mottie.github.io/tablesorter/docs/index.htmlIllnatured

© 2022 - 2024 — McMap. All rights reserved.