| 1 |
<!DOCTYPE html> |
| 2 |
<html> |
| 3 |
<head> |
| 4 |
<meta charset="utf-8"> |
| 5 |
<title>jQuery tablesorter 2.0 - Dealing with Digits</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 |
|
| 20 |
<script id="js">$(function() { |
| 21 |
// call the tablesorter plugin |
| 22 |
$("table").tablesorter({ theme : 'blue' }); |
| 23 |
});</script> |
| 24 |
</head> |
| 25 |
<body> |
| 26 |
<div id="banner"> |
| 27 |
<h1>table<em>sorter</em></h1> |
| 28 |
<h2>Dealing with digits</h2> |
| 29 |
<h3>Flexible client-side table sorting</h3> |
| 30 |
<a href="index.html">Back to documentation</a> |
| 31 |
</div> |
| 32 |
<div id="main"> |
| 33 |
|
| 34 |
<p class="tip"> |
| 35 |
<em>NOTE!</em> |
| 36 |
</p> |
| 37 |
<ul> |
| 38 |
<li>Click on any column header to sort that column.</li> |
| 39 |
<li>The alphanumeric sort working in the first column was added in version 2.0.6 (not part of the original plugin).</li> |
| 40 |
<li>The above sort was replaced with a natural sort in version 2.2.</li> |
| 41 |
<li>This example demonstrates that common table values are auto-detected (including plain text, currency, percentages, and positive & negative numbers), so there is no need to set a specific parser unless you notice an issue with how a column is sorting.</li> |
| 42 |
<li>Issues may arise if a column contains mixed data, e.g. "N/A" is located at the top of a numeric column; in this case the column will be detected as a text column and not a numeric column. If issues occur, add a <code>sorter-digit</code> class name to that header cell.</li> |
| 43 |
</ul> |
| 44 |
|
| 45 |
<h1>Demo</h1> |
| 46 |
<div id="demo"> |
| 47 |
<table class="tablesorter" data-sortlist="[[0,0]]"> |
| 48 |
<thead> |
| 49 |
<tr> |
| 50 |
<th>Account #</th> |
| 51 |
<th>First Name</th> |
| 52 |
<th>Last Name</th> |
| 53 |
<th>Age</th> |
| 54 |
<th>Total</th> |
| 55 |
<th>Discount</th> |
| 56 |
<th>Diff</th> |
| 57 |
</tr> |
| 58 |
</thead> |
| 59 |
<tbody> |
| 60 |
<tr> |
| 61 |
<td>A43</td> |
| 62 |
<td>Peter</td> |
| 63 |
<td>Parker</td> |
| 64 |
<td>28</td> |
| 65 |
<td>9.99</td> |
| 66 |
<td>20.3%</td> |
| 67 |
<td>+3</td> |
| 68 |
</tr> |
| 69 |
<tr> |
| 70 |
<td>A255</td> |
| 71 |
<td>John</td> |
| 72 |
<td>Hood</td> |
| 73 |
<td>33</td> |
| 74 |
<td>19.99</td> |
| 75 |
<td>25.1%</td> |
| 76 |
<td>-7</td> |
| 77 |
</tr> |
| 78 |
<tr> |
| 79 |
<td>A33</td> |
| 80 |
<td>Clark</td> |
| 81 |
<td>Kent</td> |
| 82 |
<td>18</td> |
| 83 |
<td>2.89</td> |
| 84 |
<td>44.2%</td> |
| 85 |
<td>-15</td> |
| 86 |
</tr> |
| 87 |
<tr> |
| 88 |
<td>A1</td> |
| 89 |
<td>Bruce</td> |
| 90 |
<td>Almighty</td> |
| 91 |
<td>45</td> |
| 92 |
<td>153.19</td> |
| 93 |
<td>44%</td> |
| 94 |
<td>+19</td> |
| 95 |
</tr> |
| 96 |
<tr> |
| 97 |
<td>A102</td> |
| 98 |
<td>Bruce</td> |
| 99 |
<td>Evans</td> |
| 100 |
<td>56</td> |
| 101 |
<td>$153.19</td> |
| 102 |
<td>23%</td> |
| 103 |
<td>+9</td> |
| 104 |
</tr> |
| 105 |
<tr> |
| 106 |
<td>A256</td> |
| 107 |
<td>John</td> |
| 108 |
<td>Clark</td> |
| 109 |
<td>44</td> |
| 110 |
<td>($19.89)</td> |
| 111 |
<td>25.1%</td> |
| 112 |
<td>(5)</td> |
| 113 |
</tr> |
| 114 |
<tr> |
| 115 |
<td>A23</td> |
| 116 |
<td>Elvis</td> |
| 117 |
<td>Presley</td> |
| 118 |
<td>24</td> |
| 119 |
<td>($9.99)</td> |
| 120 |
<td>50%</td> |
| 121 |
<td>(22)</td> |
| 122 |
</tr> |
| 123 |
<tr> |
| 124 |
<td>A10</td> |
| 125 |
<td>Frank</td> |
| 126 |
<td>Carter</td> |
| 127 |
<td>40</td> |
| 128 |
<td>-12.99</td> |
| 129 |
<td>20%</td> |
| 130 |
<td>(6)</td> |
| 131 |
</tr> |
| 132 |
</tbody> |
| 133 |
</table></div> |
| 134 |
|
| 135 |
<h1>Javascript</h1> |
| 136 |
<div id="javascript"> |
| 137 |
<pre class="prettyprint lang-javascript"></pre> |
| 138 |
</div> |
| 139 |
<h1>HTML</h1> |
| 140 |
<div id="html"> |
| 141 |
<pre class="prettyprint lang-html"></pre> |
| 142 |
</div> |
| 143 |
|
| 144 |
<div class="next-up"> |
| 145 |
<hr /> |
| 146 |
Next up: <a href="example-options-headers-digits-strings.html">Dealing with text strings in numerical sorts ››</a> |
| 147 |
</div> |
| 148 |
|
| 149 |
</div> |
| 150 |
|
| 151 |
</body> |
| 152 |
</html> |