| 1 |
<!DOCTYPE html> |
| 2 |
<html> |
| 3 |
<!-- |
| 4 |
Copyright 2010 The Closure Library Authors. All Rights Reserved. |
| 5 |
|
| 6 |
Use of this source code is governed by the Apache License, Version 2.0. |
| 7 |
See the COPYING file for details. |
| 8 |
--> |
| 9 |
<head> |
| 10 |
<title>goog.ui.TableSorter</title> |
| 11 |
<script src="../base.js"></script> |
| 12 |
<script> |
| 13 |
goog.require('goog.ui.TableSorter'); |
| 14 |
</script> |
| 15 |
<link rel="stylesheet" href="css/demo.css"> |
| 16 |
<link rel="stylesheet" href="../css/tablesorter.css"> |
| 17 |
<style> |
| 18 |
/** Each application can choose how to show sorted state. |
| 19 |
This is a simple way, just toggling background colors. */ |
| 20 |
|
| 21 |
th.goog-tablesorter-sorted { |
| 22 |
background-color: #eef; |
| 23 |
} |
| 24 |
|
| 25 |
th.goog-tablesorter-sorted-reverse { |
| 26 |
background-color: #fee; |
| 27 |
} |
| 28 |
</style> |
| 29 |
</head> |
| 30 |
<body> |
| 31 |
<h1>goog.ui.TableSorter</h1> |
| 32 |
<p> |
| 33 |
Number sorts numerically, month sorts alphabetically, and days sorts |
| 34 |
numerically in reverse. |
| 35 |
</p> |
| 36 |
<table border="0" cellpadding="3" id="sortMe"> |
| 37 |
<thead> |
| 38 |
<tr> |
| 39 |
<th>Number</th> |
| 40 |
<th>Month</th> |
| 41 |
<th>Days (non-leap year)</th> |
| 42 |
</tr> |
| 43 |
</thead> |
| 44 |
<tbody> |
| 45 |
<tr> |
| 46 |
<td>1</td> |
| 47 |
<td>January</td> |
| 48 |
<td>31</td> |
| 49 |
</tr> |
| 50 |
<tr> |
| 51 |
<td>2</td> |
| 52 |
<td>Februrary</td> |
| 53 |
<td>28</td> |
| 54 |
</tr> |
| 55 |
<tr> |
| 56 |
<td>3</td> |
| 57 |
<td>March</td> |
| 58 |
<td>31</td> |
| 59 |
</tr> |
| 60 |
<tr> |
| 61 |
<td>4</td> |
| 62 |
<td>April</td> |
| 63 |
<td>30</td> |
| 64 |
</tr> |
| 65 |
<tr> |
| 66 |
<td>5</td> |
| 67 |
<td>May</td> |
| 68 |
<td>31</td> |
| 69 |
</tr> |
| 70 |
<tr> |
| 71 |
<td>6</td> |
| 72 |
<td>June</td> |
| 73 |
<td>30</td> |
| 74 |
</tr> |
| 75 |
<tr> |
| 76 |
<td>7</td> |
| 77 |
<td>July</td> |
| 78 |
<td>31</td> |
| 79 |
</tr> |
| 80 |
<tr> |
| 81 |
<td>8</td> |
| 82 |
<td>August</td> |
| 83 |
<td>31</td> |
| 84 |
</tr> |
| 85 |
<tr> |
| 86 |
<td>9</td> |
| 87 |
<td>September</td> |
| 88 |
<td>30</td> |
| 89 |
</tr> |
| 90 |
<tr> |
| 91 |
<td>10</td> |
| 92 |
<td>October</td> |
| 93 |
<td>31</td> |
| 94 |
</tr> |
| 95 |
<tr> |
| 96 |
<td>11</td> |
| 97 |
<td>November</td> |
| 98 |
<td>30</td> |
| 99 |
</tr> |
| 100 |
<tr> |
| 101 |
<td>12</td> |
| 102 |
<td>December</td> |
| 103 |
<td>31</td> |
| 104 |
</tr> |
| 105 |
</tbody> |
| 106 |
</table> |
| 107 |
<br/> |
| 108 |
<script> |
| 109 |
var component = new goog.ui.TableSorter(); |
| 110 |
component.decorate(goog.dom.getElement('sortMe')); |
| 111 |
component.setSortFunction(1, goog.ui.TableSorter.alphaSort); |
| 112 |
component.setSortFunction(2, |
| 113 |
goog.ui.TableSorter.createReverseSort(goog.ui.TableSorter.numericSort)); |
| 114 |
</script> |
| 115 |
</body> |
| 116 |
</html> |