Anyone used Tablesorter jQuery?

Soldato
Joined
25 Mar 2004
Posts
16,007
Location
Fareham
Hi all,

I'm writing a page at work that takes a CSV input and uses C# to read the CSV contents into the page.

I wanted to make this table sortable and have the zebra stripe effect (i.e every other row has a different style attached to it). So far using the jQuery tablesorter plugin I have been able to get the sorting functional, but it seems that I can't get the Zebra effect working.

This is the plugin I am talking about:

http://tablesorter.com/docs/

This is the code I am using to load the tablesorted plugin:

Code:
<head>

		<title>Disks</title>

		<link href="CSS\style.css" rel="stylesheet" type="text/css" />

		<script type="text/javascript" src="jquery-1.6.1.min.js"></script>
		<script type="text/javascript" src="jquery.tablesorter.min.js"></script>

	<script type="text/javascript" id="js">
	$(document).ready(function() {
		// call the tablesorter plugin
		$("table").tablesorter({
		widgets: ['zebra']
		});
	}); 
	</script>
		
	</head>

According to my searches across the net the addition of the line:

widgets: ['zebra']

Should tell it to use the built in zebra widget, however when I do this it makes no discernible difference to my page/source code after generating the page.

Anyone used this with success? I'm probably doing something stupid :P

Thanks!
 
While they do have a built in widget system, the widgets themselves need to be added as needed.

The js you need is in the first example on the widget demo page.
http://tablesorter.com/docs/example-widgets.html

Thanks, think I had that in already as it was imported in one of the <script> variables at the top, in the end I added this to my CSS after checking the example, and then it worked :)

Code:
tbody tr.odd td {
	background-color:#F0F0F6;
}
 
Back
Top Bottom