views:

33

answers:

1

I have a set of about 40 records in a list which works inside a table with pagination, 10 records per page and sorting enabled on all the columns. My problem is, pagination doesn't appear to work with the sortForce option. When implementing it, the page will "work" (as in load) on the first load, and when clicking on one of the columns (that isn't the sortForce column) the pagination explodes in a literal fashion and displays all the records on the same page suddenly.

The sorting then locks in only one direction, you can sort only in whatever direction the sortForce initially described (asc or desc), but for ALL columns (so you can't sort asc by column 1 let's say, if sortForce said desc for the sortForce on whichever column you are sorting by). Let's see if I can whip up a sample:

$(document).ready(function() { 
    $("table").tablesorter({sortForce: [[2,0]]});
    $("table").tablesorter({widthFixed: true, widgets: ['zebra']}).tablesorterPager({container: $("#pager")});
}); 

Try that with any table set, you can grab a set of tables for your testing from the source code here:

http://tablesorter.com/docs/example-pager.html

If what I am trying to do here, force a sort on once column while being able to then set a secondary sort on other columns while including pagination, seems easier to do with another solution, I am wide open to suggestions.

A: 

The answer was doing all the sorting under one tablesorter instead of splitting it up. Here is the solution:

jQuery("#table").tablesorter({widthFixed: true,
    sortForce: [[10,0]],
    sortList:  [[10,0]],
    widgets:   ['zebra']}).tablesorterPager({container: jQuery("#pager")});

sortList was required in order to do the initial sort. Setting sortForce makes sure the sort stays after sorting with other columns.

Organiccat