I am using the TableSorter and Pager plugin from here: http://tablesorter.com/docs/
I want the table to display results starting at some defined index- for example, if my index is 14, I want the table to display the 'page' of results 11-20, so my row is shown, rather than starting at the default page 1, showing results 1-10.
I have this working as expected, but with some fairly ugly code..
First I work out the page that needs to be displayed (C#):
int index = 24;
int pageToDisplayFirst = 1;
while (true)
{
if (index - 10 > 0)
{
pageToDisplayFirst++;
index -= 10;
}
else
{
break;
}
}
Then I set the page by this awful loop:
for(var i = 0; i < <%= pageToDisplayFirst %>; i++) {
$(".next").trigger("click");
}
Here is the jQuery initialisation code, nothing special:
$("table.tablesorter").tablesorter({
cssAsc: 'sortasc', cssDesc: 'sortdesc', cssHeader: 'unsorted',
sortList: [[0,0]]
}).tablesorterPager({container: $("#pager")});
So can anyone suggest a more elegant, efficient solution?