Tablesorter demo
All options included, as well as the uitheme widget
by secretgspot
HTML
<link rel="stylesheet" href="http://tablesorter.com/themes/blue/style.css">
<script src="http://tablesorter.com/__jquery.tablesorter.min.js"></script>
<script src="http://tablesorter.com/addons/pager/jquery.tablesorter.pager.js"></script>
<div id="pager" class="pager">
<form>
<input type="button" value="<<" class="first" />
<input type="button" value="<" class="prev" />
<input type="text" class="pagedisplay"/>
<input type="button" value=">" class="next" />
<input type="button" value=">>" class="last" />
<select class="pagesize">
<option selected="selected" value="10">10</option>
<option value="20">20</option>
<option value="30">30</option>
<option value="40">40</option>
</select>
</form>
</div>
<table class="grid tablesorter" cellspacing="0" style="width: auto;">
<colgroup>
<col width="19" />
<col width="85" />
<col width="250" />
<col width="100" />
<col width="90" />
<col width="70" />
</colgroup>
<thead>
<tr>
<th style="padding: 0; margin: 0;"></th>
<th>
Order #
</th>
<th>
Customer
</th>
<th>
PO
</th>
<th>
Date
</th>
<th>
Total
</th>
</tr>
</thead>
<tbody>
<tr>
<td rowspan="2" class="collapsible">
</td>
<td rowspan="2" class="collapsible_alt">
<a href="javascript:alert('Order # SO71774')">SO71774</a>
</td>
<td>
Good Toys
</td>
<td>
PO348186287
</td>
<td>
Jul 20, 2007
</td>
<td>
$972.78
</td>
...
CSS
table.tablesorter .expand-child.odd td,
table.tablesorter .expand-child.even td {
background: #7ff;
}
table.grid {
margin: 0;
padding: 0;
border-collapse: separate;
border-spacing: 0;
width: 100%;
}
table.grid * {
font: 11px Arial, Helvetica, sans-serif;
vertical-align: top;
text-align: left;
}
/* use the below style below to hide the collapsed rows via CSS, you must also set the showCollapsed setting to true */
/*
table.grid tr.expand-child td {
display: none;
}
*/
table.grid th {
color: #565770;
padding: 4px 16px 4px 0;
cursor: pointer;
}
table.grid td {
color: #565770;
padding: 4px 6px;
}
table.grid th span {
padding: 4px 0 4px 6px;
font-weight: bold;
}
table.grid a:link,
table.grid a:visited,
table.grid a:focus,
table.grid a:hover {
color: #565770;
font-weight: bold;
text-decoration: underline;
}
table.grid a:hover {
color: #d07c57;
}
table.grid tr.even {
background-color: #f0f0f0;
}
/* expand/collapse */
table.grid .collapsible {
padding: 0 0 3px 0;
}
div.tablesorterPager {
padding: 10px 0 10px 0;
background-color: #D6D2C2;
text-align: center;
}
div.tablesorterPager span {
padding: 0 5px 0 5px;
}
div.tablesorterPager input.prev {
width: auto;
margin-right: 10px;
}
div.tablesorterPager input.next {
width: auto;
margin-left: 10px;
}
div.tablesorterPager input {
font-size: 8px;
width: 50px;
border: 1px solid #330000;
text-align: center;
}
tr td.collapsible:after {
display:block;
text-align: center;
content: "+";
}
tr.showing td.collapsible:after {
display:block;
text-align: center;
content: "-";
}
JavaScript
$(document).ready(
function() {
$(".tablesorter").tablesorter({
// set default sort column
sortList: [[4, 0]],
// don't sort by first column
headers: {
0: {
sorter: false
}
}
// set the widgets being used - zebra stripping
,
widgets: ['zebra'],
onRenderHeader: function() {
this.wrapInner("<span></span>");
},
debug: false
}).tablesorterPager({
container: $("#pager"),
positionFixed: false
});
});
$('td.collapsible').click(function() {
$(this).closest('tr').toggleClass('showing').next().find('td').toggle();
});
$('.expand-child td').hide();