Debian Codegraph @

docs/example-option-sort-empty.html

raw symbols SCIP
1 <!DOCTYPE html>
2 <html>
3 <head>
4 <meta charset="utf-8">
5 <title>jQuery tablesorter 2.0 - Sorting empty cells</title>
6
7 <!-- jQuery -->
8 <script src="js/jquery-latest.min.js"></script>
9
10 <!-- Demo stuff -->
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 <!-- Tablesorter: required -->
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({
23 theme : 'blue',
24
25 // default "emptyTo"
26 emptyTo: 'bottom'
27 });
28 });</script>
29
30 <script>
31 $(function() {
32 $('select').change(function() {
33 var t = $('table'),
34 v = $(this).val();
35 t[0].config.emptyTo = v;
36 t.trigger("update");
37 });
38 });
39 </script>
40 </head>
41 <body>
42 <div id="banner">
43 <h1>table<em>sorter</em></h1>
44 <h2>Sorting empty cells</h2>
45 <h3>Flexible client-side table sorting</h3>
46 <a href="index.html">Back to documentation</a>
47 </div>
48 <div id="main">
49
50 <p class="tip">
51 <em>NOTE!</em>
52 </p>
53 <ul>
54 <li>Set the <code>emptyTo</code> selector below:
55 <ul>
56 <li><code>bottom</code> - sort empty table cells to the bottom.</li>
57 <li><code>top</code> - sort empty table cells to the top.</li>
58 <li><code>emptyMax</code> - sort empty table cells as having a value greater than the <em>max</em> (more positive) value (added v2.16.2)</li>
59 <li><code>emptyMin</code> - sort empty table cells as having a value greater than the <em>min</em> (more negative) value (added v2.16.2)</li>
60 <li><code>none</code> or <code>zero</code>
61 <ul>
62 <li>Sort empty table cells as if the cell has the value equal to zero</li>
63 <li>None/zero has a value less than A through Z (in javascript, <code>0 &lt; 'A' && 0 &lt; 'Z'</code>); so in an alphabetical column, empty cells will sort at the top in an ascending sort &amp; at the bottom in a descending sort.</li>
64 <li>In numerical columns, empty cells will sort as if their value was zero.</li>
65 </ul>
66 </li>
67 </ul>
68 <br>
69 </li>
70 <li>Individual columns can be modified by adding the following (they all do the same thing), set in order of priority:
71 <ul>
72 <li>jQuery data <code>data-empty="top"</code>.</li>
73 <li>metadata <code>class="{ empty: 'top'}"</code>. This requires the metadata plugin.</li>
74 <li>headers option <code>headers : { 0 : { empty : 'top' } }</code>.</li>
75 <li>header class name <code>class="empty-top"</code>.</li>
76 <li>Overall <code>emptyTo</code> option.</li>
77 </ul>
78 <br>
79 </li>
80 <li><code>emptyToBottom</code> option was added in v2.1.11, then replaced by the <code>emptyTo</code> option in v2.1.16.</li>
81 </ul>
82
83 <h1>Demo</h1>
84
85 Set <code>emptyTo</code> option: <select>
86 <option>bottom</option>
87 <option>top</option>
88 <option>emptyMax</option>
89 <option>emptyMin</option>
90 <option value="zero">none/zero</option>
91 </select>
92
93 <div id="demo"><table class="tablesorter">
94 <thead>
95 <tr>
96 <th class="empty-top">*Account #</th> <!-- empty-top class has higher priority than the "emptyTo" option -->
97 <th>First Name</th>
98 <th>Last Name</th>
99 <th>Age</th>
100 <th>Total</th>
101 <th>Discount</th>
102 <th>Diff</th>
103 </tr>
104 </thead>
105 <tbody>
106 <tr>
107 <td>A43</td>
108 <td>Peter</td>
109 <td>Parker</td>
110 <td>28</td>
111 <td></td>
112 <td>20.3%</td>
113 <td>+3</td>
114 </tr>
115 <tr>
116 <td>A255</td>
117 <td></td>
118 <td>Hood</td>
119 <td></td>
120 <td>19.99</td>
121 <td>25.1%</td>
122 <td>-7</td>
123 </tr>
124 <tr>
125 <td></td>
126 <td>Clark</td>
127 <td></td>
128 <td>18</td>
129 <td>15.89</td>
130 <td>44.2%</td>
131 <td>-15</td>
132 </tr>
133 <tr>
134 <td>A1</td>
135 <td>Bruce</td>
136 <td>Almighty</td>
137 <td>45</td>
138 <td>153.19</td>
139 <td></td>
140 <td>+19</td>
141 </tr>
142 <tr>
143 <td>A102</td>
144 <td>Bruce</td>
145 <td>Evans</td>
146 <td>56</td>
147 <td>153.19</td>
148 <td>23%</td>
149 <td></td>
150 </tr>
151 <tr>
152 <td>A109</td>
153 <td>Larry</td>
154 <td>Stevens</td>
155 <td>56</td>
156 <td>153.19</td>
157 <td>23%</td>
158 <td>0</td>
159 </tr>
160 <tr>
161 <td>A99</td>
162 <td>John</td>
163 <td>Smithy</td>
164 <td>56</td>
165 <td>156</td>
166 <td>22%</td>
167 <td></td>
168 </tr>
169 <tr>
170 <td>A119</td>
171 <td>Mike</td>
172 <td>Rowe</td>
173 <td>55</td>
174 <td>-53.99</td>
175 <td>13%</td>
176 <td>0</td>
177 </tr>
178 </tbody>
179 </table></div>
180 * <span class="label label-info">Note</span> The "Account #" column has the "empty-top" class name set which over-rides the <code>emptyTo</code> option (see the order of priority note above).
181 <p></p>
182
183 <h1>Javascript</h1>
184 <div id="javascript">
185 <pre class="prettyprint lang-javascript"></pre>
186 </div>
187 <h1>HTML</h1>
188 <div id="html">
189 <pre class="prettyprint lang-html"></pre>
190 </div>
191
192 <div class="next-up">
193 <hr />
194 Next up: <a href="example-option-sort-key.html">Change the default multi-sorting key &rsaquo;&rsaquo;</a>
195 </div>
196
197 </div>
198
199 </body>
200 </html>