Sortable-dl is a project mainly written in JavaScript, it's free.
There are a few excellent plugins for jQuery for Table sorting. But none offers an option for extra content ('more information ..'), hidden per default and with valid Markup. SortableDL uses standard tables with a little 'Markup Hack'.
Instead:
<tr>
<td class="col1"></td>
<td class="col2"></td>
<td class="col3"></td>
</tr>
we take Definition List Elements for columns:
<tr>
<td>
<dl>
<dt class="col1"></dt>
<dt class="col2"></dt>
<dt class="col3"></dt>
</dl>
</td>
</tr>
Now we can add DD element(s) for the extra content (hidden per default) :
<tr>
<td>
<dl>
<dt class="col1"></dt>
<dt class="col2"></dt>
<dt class="col3"></dt>
<dd>additional content</dd>
<dd>more additional content</dd>
</dl>
</td>
</tr>
To use the sortable-dl, include the jQuery library and the sortable-dl script and stylesheet inside the <head> tag of your HTML document:
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.min.js"></script>
<link rel="stylesheet" type="text/css" href="sortable-dl.css">
<script src="sortable-dl.min.js"></script>
NOTE: sortable-dl works NOT on standard HTML tables (more than one table cell in row). As described before, it used a definition list hack for hiding and showing extra information for any table row:
|
|
|
Start by creating a new instance of SortableDL and init with your options to sort the table when the document is loaded:
<script>
$(document).ready(function() {
var mySorter = new SortableDL();
mySorter.init({
id: 'sortable', // Table ID
first: 'ascending', // optional / default 'descending'
columns: [
null, // Col 1
'caseInsensitive', // Col 2
'caseSensitive', // Col 3
'numeric', // Col 4
'numeric', // Col 5
'date', // Col 6
null // Col 7
],
classes: {
asc: 'asc', // optional - default: 'asc'
desc: 'desc', // optional - default: 'desc'
column: 'active-column' // optional - default: ''
},
pagination: { // optional - default: 'no pager'
items: 5, // Items per page: optional - default: 'all'
numbers: 5 // Visible page numbers: optional - default: 'all'
}
});
});
</script>
Sort by date accepts following date formats:
You can create multiple pagers (normally at the top and bottom of the sortable table) with the following HTML fragment: