Dónal
Dónal

Reputation: 187537

preserve zebra striping with jquery tablesorter plugin

The table on this page is sorted by the tablesorter plugin. The candy-striping is not re-applied after sorting, so the shaded and unshaded rows appear in the wrong sequence after a sort is performed. Click on the Name column to see an example of this.

Is there a way to redo the striping after a sort?

Upvotes: 2

Views: 4100

Answers (2)

Adam
Adam

Reputation: 95

I've also found that you can solve this problem like this:

$('your_table').tablesorter({
    widgets: ['zebra'],
    widgetZebra: { css: ['normal-row', 'alt-row' ] }
});

Found here: http://wowmotty.blogspot.com/2011/06/jquery-tablesorter-missing-docs.html

In my case, just initializing the zebra widget would not actually apply the table striping, even though I had the CSS classes .even and .odd defined (which I believe are the default classes that the zebra widget assigns).

Upvotes: 3

Joseph Silber
Joseph Silber

Reputation: 219936

You have to use the zebra widget. Use the following piece of code to initialize the tablesorter:

$("table.tablesorter").tablesorter({
    widgets: ['zebra']
});

Zebra is the only widget included by default. See here for reference.

Upvotes: 10

Related Questions