Debian Codegraph @

docs/example-options-headers-digits-strings.html

raw symbols SCIP
1 <!DOCTYPE html>
2 <html>
3 <head>
4 <meta charset="utf-8">
5 <title>jQuery tablesorter 2.0 - Dealing with text strings in numerical sorts</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 <style>
19 th { width: 10%; }
20 </style>
21 <script src="../js/jquery.tablesorter.js"></script>
22
23 <script id="js">$(function() {
24 // call the tablesorter plugin
25 $("table").tablesorter({
26 theme : 'blue',
27 // default strings setting
28 stringTo: "max",
29 // columns 2 & 3 (zero-based index) set using headers option
30 // columns 4+ set using header class name: "string-max", "string-min", "string-top", "string-bottom" and "string-none"
31 headers: {
32 1: { sorter: "digit", empty : "top" }, // sort empty cells to the top
33 2: { sorter: "digit", string: "max" }, // non-numeric content is treated as a MAX value
34 3: { sorter: "digit", string: "min" } // non-numeric content is treated as a MIN value
35 }
36
37 });
38 });</script>
39 </head>
40 <body>
41 <div id="banner">
42 <h1>table<em>sorter</em></h1>
43 <h2>Dealing with text strings in numerical sorts</h2>
44 <h3>Flexible client-side table sorting</h3>
45 <a href="index.html">Back to documentation</a>
46 </div>
47 <div id="main">
48
49 <p class="tip">
50 <em>NOTE!</em>
51 </p>
52 <ul>
53 <li>This functionality is new as of version 2.0.10 (not part of the original plugin).</li>
54 <li>When a column is sorted numerically ( <code>sorter:"digit"</code> ) any text in that column will, by default, be given a <em>zero</em> value. Sort the last column (#9) to see the problem with this method.</li>
55 <li>Overall <code>stringTo</code> option added in version 2.1.16.</li>
56 <li>String options changed in version 2.1.16; setting the value to:
57 <ul>
58 <li><code>"max"</code> will treat any text in that column as a value greater than the <em>max</em> (more positive) value. Renamed from "max+".</li>
59 <li><code>"min"</code> will treat any text in that column as a value greater than the <em>min</em> (more negative) value. Renamed from "max-".</li>
60 <li><code>"top"</code> will always sort the text to the top of the column.</li>
61 <li><code>"bottom"</code> will always sort the text to the bottom of the column.</li>
62 <li><code>"none"</code> or <code>"zero"</code> will treat the text as if it has a value of zero.</li>
63 </ul>
64 </li>
65 <li>Individual columns can be modified by adding the following (they all do the same thing), set in order of priority:
66 <ul>
67 <li>jQuery data <code>data-string="top"</code>.</li>
68 <li>metadata <code>class="{ string: 'top'}"</code>. This requires the metadata plugin.</li>
69 <li>headers option <code>headers : { 0 : { string : 'top' } }</code>.</li>
70 <li>header class name <code>class="string-top"</code>.</li>
71 <li>Overall <code>stringTo</code> option.</li>
72 </ul>
73 </li>
74 <li>Sort columns three through eight to see how the sort has changed. Note that the text is sorted separately from the numeric values.</li>
75 <li>The <code>emptyTo</code> option defaults to bottom, so all empty cells will sort at the bottom of the table, except for the second column.</li>
76 </ul>
77
78 <h1>Demo</h1>
79 <div id="demo"><table>
80 <thead>
81 <tr>
82 <th>Account #</th>
83 <th>Difference</th>
84 <th>3: Ratings (max)</th>
85 <th>4: Ratings (min)</th>
86 <th class="string-max">5: Change (max)</th>
87 <th class="string-min">6: Change (min)</th>
88 <th class="string-top">7: Change (top)</th>
89 <th class="string-bottom">8: Change (bottom)</th>
90 <th class="string-none">9: Change (zero)</th>
91 </tr>
92 </thead>
93 <tbody>
94 <tr>
95 <td>A43</td>
96 <td>-35</td>
97 <td>01</td>
98 <td>01</td>
99 <td>-.1</td>
100 <td>-.1</td>
101 <td>-.1</td>
102 <td>-.1</td>
103 <td>-.1</td>
104 </tr>
105 <tr>
106 <td>A255</td>
107 <td>33</td>
108 <td>02</td>
109 <td>02</td>
110 <td>N/A #1</td>
111 <td>N/A #1</td>
112 <td>N/A #1</td>
113 <td>N/A #1</td>
114 <td>N/A #1</td>
115 </tr>
116 <tr>
117 <td>A33</td>
118 <td>2</td>
119 <td>03</td>
120 <td>03</td>
121 <td>N/A #2</td>
122 <td>N/A #2</td>
123 <td>N/A #2</td>
124 <td>N/A #2</td>
125 <td>N/A #2</td>
126 </tr>
127 <tr>
128 <td>A1</td>
129 <td>-5</td>
130 <td>04</td>
131 <td>04</td>
132 <td>-8.4</td>
133 <td>-8.4</td>
134 <td>-8.4</td>
135 <td>-8.4</td>
136 <td>-8.4</td>
137 </tr>
138 <tr>
139 <td>A102</td>
140 <td>99</td>
141 <td>05</td>
142 <td>05</td>
143 <td>-2.2</td>
144 <td>-2.2</td>
145 <td>-2.2</td>
146 <td>-2.2</td>
147 <td>-2.2</td>
148 </tr>
149 <tr>
150 <td>A10</td>
151 <td>-1</td>
152 <td>06</td>
153 <td>06</td>
154 <td>97.4</td>
155 <td>97.4</td>
156 <td>97.4</td>
157 <td>97.4</td>
158 <td>97.4</td>
159 </tr>
160 <tr>
161 <td>A02</td>
162 <td>0</td>
163 <td>07</td>
164 <td>07</td>
165 <td>23.6</td>
166 <td>23.6</td>
167 <td>23.6</td>
168 <td>23.6</td>
169 <td>23.6</td>
170 </tr>
171 <tr>
172 <td>A55</td>
173 <td>44</td>
174 <td></td>
175 <td></td>
176 <td>11.4</td>
177 <td>11.4</td>
178 <td>11.4</td>
179 <td>11.4</td>
180 <td>11.4</td>
181 </tr>
182 <tr>
183 <td>A87</td>
184 <td>04</td>
185 <td>NR</td>
186 <td>NR</td>
187 <td>5.2</td>
188 <td>5.2</td>
189 <td>5.2</td>
190 <td>5.2</td>
191 <td>5.2</td>
192 </tr>
193 <tr>
194 <td>A012</td>
195 <td></td>
196 <td>NR</td>
197 <td>NR</td>
198 <td></td>
199 <td></td>
200 <td></td>
201 <td></td>
202 <td></td>
203 </tr>
204 </tbody>
205 </table></div>
206
207 <h1>Javascript</h1>
208 <div id="javascript">
209 <pre class="prettyprint lang-javascript"></pre>
210 </div>
211 <h1>HTML</h1>
212 <div id="html">
213 <pre class="prettyprint lang-html"></pre>
214 </div>
215
216 <div class="next-up">
217 <hr />
218 Next up: <a href="example-parsers-class-name.html">Disable or set the column parser using class names &rsaquo;&rsaquo;</a>
219 </div>
220
221 </div>
222
223 </body>
224 </html>