| 1 |
<!DOCTYPE html> |
| 2 |
<html> |
| 3 |
<head> |
| 4 |
<meta charset="utf-8"> |
| 5 |
<title>jQuery tablesorter 2.0 - currentSort widget</title> |
| 6 |
|
| 7 |
|
| 8 |
<script src="js/jquery-latest.min.js"></script> |
| 9 |
|
| 10 |
|
| 11 |
<link rel="stylesheet" href="css/jq.css"> |
| 12 |
<link href="css/prettify.css" rel="stylesheet"> |
| 13 |
<script src="js/prettify.js"></script> |
| 14 |
<script src="js/docs.js"></script> |
| 15 |
|
| 16 |
|
| 17 |
<link rel="stylesheet" href="../css/theme.blue.css"> |
| 18 |
<script src="../js/jquery.tablesorter.js"></script> |
| 19 |
<script src="../js/widgets/widget-currentSort.js"></script> |
| 20 |
<style> |
| 21 |
#display li:last-child { color: #008080; } |
| 22 |
</style> |
| 23 |
|
| 24 |
<script id="js">$(function() { |
| 25 |
|
| 26 |
$.tablesorter.currentSortLanguage = { |
| 27 |
0: 'asc', |
| 28 |
1: 'desc', |
| 29 |
2: 'unsorted' |
| 30 |
}; |
| 31 |
|
| 32 |
$('table').tablesorter({ |
| 33 |
theme: 'blue', |
| 34 |
widgets : ['zebra', 'currentSort'], |
| 35 |
widgetOptions: { |
| 36 |
currentSort_callback: function(config, values) { |
| 37 |
// values also contained in config.currentSort |
| 38 |
// update display |
| 39 |
var $display = $('#display'); |
| 40 |
$display |
| 41 |
.append('<li>[ "' + values.join('", "') + '" ]</li>') |
| 42 |
.find('li:first').remove(); |
| 43 |
} |
| 44 |
} |
| 45 |
}); |
| 46 |
|
| 47 |
}); </script> |
| 48 |
</head> |
| 49 |
<body> |
| 50 |
|
| 51 |
<div id="banner"> |
| 52 |
<h1>table<em>sorter</em></h1> |
| 53 |
<h2>currentSort Widget</h2> |
| 54 |
<h3>Flexible client-side table sorting</h3> |
| 55 |
<a href="index.html">Back to documentation</a> |
| 56 |
</div> |
| 57 |
|
| 58 |
<div id="main"> |
| 59 |
|
| 60 |
<p class="tip"> |
| 61 |
<em>NOTE!</em> |
| 62 |
</p> |
| 63 |
<ul> |
| 64 |
<li>Added <span class="verison">v2.27.0</span>. |
| 65 |
<ul> |
| 66 |
<li>This widget has only one option - <code>currentSort_callback</code> - which provides the following parameters. |
| 67 |
<ul> |
| 68 |
<li><code>config</code> - The <code>table.config</code> object.</li> |
| 69 |
<li><code>values</code> - An array of the current sort using the <code>$.tablesorter.currentSortLanguage</code> settings.</li> |
| 70 |
</ul> |
| 71 |
</li> |
| 72 |
<li>Change the language of the output for this widget by modifying the <code>$.tablesorter.currentSortLanguage</code> object.</li> |
| 73 |
<li>The current sort array is also saved to <code>config.currentSort</code>.</li> |
| 74 |
</ul> |
| 75 |
</li> |
| 76 |
</ul> |
| 77 |
|
| 78 |
<h1>Current Sort</h1> |
| 79 |
<ul id="display"> |
| 80 |
<li>The last three sort arrays will appear here.</li> |
| 81 |
<li> </li> |
| 82 |
<li> </li> |
| 83 |
</ul> |
| 84 |
|
| 85 |
<h1>Demo</h1> |
| 86 |
<table class="tablesorter"> |
| 87 |
<thead> |
| 88 |
<tr> |
| 89 |
<th>AlphaNumeric Sort</th> |
| 90 |
<th>Currency</th> |
| 91 |
<th>Alphabetical</th> |
| 92 |
<th>Sites</th> |
| 93 |
</tr> |
| 94 |
</thead> |
| 95 |
<tbody> |
| 96 |
<tr><td>abc 123</td><td>£10,40</td><td>Koala</td><td>http://www.google.com</td></tr> |
| 97 |
<tr><td>abc 1</td><td>£234,10</td><td>Ox</td><td>http://www.yahoo.com</td></tr> |
| 98 |
<tr><td>abc 9</td><td>£10,33</td><td>Girafee</td><td>http://www.facebook.com</td></tr> |
| 99 |
<tr><td>zyx 24</td><td>£10</td><td>Bison</td><td>http://www.whitehouse.gov/</td></tr> |
| 100 |
<tr><td>abc 11</td><td>£3,20</td><td>Chimp</td><td>http://www.ucla.edu/</td></tr> |
| 101 |
<tr><td>abc 2</td><td>£56,10</td><td>Elephant</td><td>http://www.wikipedia.org/</td></tr> |
| 102 |
<tr><td>abc 9</td><td>£3,20</td><td>Lion</td><td>http://www.nytimes.com/</td></tr> |
| 103 |
<tr><td>ABC 10</td><td>£87,00</td><td>Zebra</td><td>https://github.com</td></tr> |
| 104 |
<tr><td>zyx 1</td><td>£99,90</td><td>Koala</td><td>http://www.mit.edu/</td></tr> |
| 105 |
<tr><td>zyx 12</td><td>£234,10</td><td>Llama</td><td>http://www.nasa.gov/</td></tr> |
| 106 |
</tbody> |
| 107 |
</table> |
| 108 |
|
| 109 |
<h1>Javascript</h1> |
| 110 |
<div id="javascript"> |
| 111 |
<pre class="prettyprint lang-javascript"></pre> |
| 112 |
</div> |
| 113 |
|
| 114 |
</div> |
| 115 |
|
| 116 |
</body> |
| 117 |
</html> |