Debian Codegraph @

docs/example-pager-filtered.html

raw symbols SCIP
1 <!DOCTYPE html>
2 <html>
3 <head>
4 <meta charset="utf-8">
5 <title>jQuery tablesorter 2.0 - Pager plugin + Filter widget</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 <!-- Tablesorter: optional -->
21 <link rel="stylesheet" href="../addons/pager/jquery.tablesorter.pager.css">
22 <script src="../addons/pager/jquery.tablesorter.pager.js"></script>
23 <script src="../js/jquery.tablesorter.widgets.js"></script>
24
25 <script id="js">$(function() {
26
27 var $table = $('table'),
28 // define pager options
29 pagerOptions = {
30 // target the pager markup - see the HTML block below
31 container: $(".pager"),
32 // output string - default is '{page}/{totalPages}';
33 // possible variables: {size}, {page}, {totalPages}, {filteredPages}, {startRow}, {endRow}, {filteredRows} and {totalRows}
34 // also {page:input} & {startRow:input} will add a modifiable input in place of the value
35 output: '{startRow} - {endRow} / {filteredRows} ({totalRows})',
36 // if true, the table will remain the same height no matter how many records are displayed. The space is made up by an empty
37 // table row set to a height to compensate; default is false
38 fixedHeight: true,
39 // remove rows from the table to speed up the sort of large tables.
40 // setting this to false, only hides the non-visible rows; needed if you plan to add/remove rows with the pager enabled.
41 removeRows: false,
42 // go to page selector - select dropdown that sets the current page
43 cssGoto: '.gotoPage'
44 };
45
46 // Initialize tablesorter
47 // ***********************
48 $table
49 .tablesorter({
50 theme: 'blue',
51 headerTemplate : '{content} {icon}', // new in v2.7. Needed to add the bootstrap icon!
52 widthFixed: true,
53 widgets: ['zebra', 'filter']
54 })
55
56 // initialize the pager plugin
57 // ****************************
58 .tablesorterPager(pagerOptions);
59
60 // Add two new rows using the "addRows" method
61 // the "update" method doesn't work here because not all rows are
62 // present in the table when the pager is applied ("removeRows" is false)
63 // ***********************************************************************
64 var r, $row, num = 50,
65 row = '<tr><td>Student{i}</td><td>{m}</td><td>{g}</td><td>{r}</td><td>{r}</td><td>{r}</td><td>{r}</td><td><button type="button" class="remove" title="Remove this row">X</button></td></tr>' +
66 '<tr><td>Student{j}</td><td>{m}</td><td>{g}</td><td>{r}</td><td>{r}</td><td>{r}</td><td>{r}</td><td><button type="button" class="remove" title="Remove this row">X</button></td></tr>';
67 $('button:contains(Add)').click(function() {
68 // add two rows of random data!
69 r = row.replace(/\{[gijmr]\}/g, function(m) {
70 return {
71 '{i}' : num + 1,
72 '{j}' : num + 2,
73 '{r}' : Math.round(Math.random() * 100),
74 '{g}' : Math.random() > 0.5 ? 'male' : 'female',
75 '{m}' : Math.random() > 0.5 ? 'Mathematics' : 'Languages'
76 }[m];
77 });
78 num = num + 2;
79 $row = $(r);
80 $table
81 .find('tbody').append($row)
82 .trigger('addRows', [$row]);
83 return false;
84 });
85
86 // Delete a row
87 // *************
88 $table.delegate('button.remove', 'click' ,function() {
89 // NOTE this special treatment is only needed if `removeRows` is `true`
90 // disabling the pager will restore all table rows
91 $table.trigger('disablePager');
92 // remove chosen row
93 $(this).closest('tr').remove();
94 // restore pager
95 $table.trigger('enablePager');
96 });
97
98 // Destroy pager / Restore pager
99 // **************
100 $('button:contains(Destroy)').click(function() {
101 // Exterminate, annhilate, destroy! http://www.youtube.com/watch?v=LOqn8FxuyFs
102 var $t = $(this);
103 if (/Destroy/.test( $t.text() )) {
104 $table.trigger('destroyPager');
105 $t.text('Restore Pager');
106 } else {
107 $table.tablesorterPager(pagerOptions);
108 $t.text('Destroy Pager');
109 }
110 return false;
111 });
112
113 // Disable / Enable
114 // **************
115 $('.toggle').click(function() {
116 var mode = /Disable/.test( $(this).text() );
117 // triggering disablePager or enablePager
118 $table.trigger( (mode ? 'disable' : 'enable') + 'Pager');
119 $(this).text( ( mode ? 'Enable' : 'Disable' ) + ' Pager');
120 return false;
121 });
122 $table.bind('pagerChange', function() {
123 // pager automatically enables when table is sorted.
124 $('.toggle').text( 'Disable Pager' );
125 });
126
127 });</script>
128 </head>
129 <body id="pager-demo">
130 <div id="banner">
131 <h1>table<em>sorter</em></h1>
132 <h2>Pager plugin + Filter widget</h2>
133 <h3>Flexible client-side table sorting</h3>
134 <a href="index.html">Back to documentation</a>
135 </div>
136
137 <div id="main">
138
139 <p class="tip">
140 <em>NOTE!</em> The following are not part of the original plugin:
141 </p>
142 <ul>
143 <li>In <span class="version updated">v2.23.0</span>, the following methods were changed due to issues with unique namespacing.
144 <ul>
145 <li><code>destroy.pager</code> is now <code>destroyPager</code></li>
146 <li><code>disable.pager</code> is now <code>disablePager</code></li>
147 <li><code>enable.pager</code> is now <code>enablePager</code></li>
148 </ul>
149 </li>
150 <li>When using this pager plugin with the filter widget, make sure that the <code>removeRows</code> option is set to <code>false</code> or it won't work.</li>
151 <li>This combination was not possible in tablesorter versions prior to version 2.4.</li>
152 <li>This combination can not be applied to the original tablesorter.</li>
153 </ul>
154
155 <h1>Demo</h1>
156 <br>
157 <button type="button">Add Rows</button> <button type="button" class="toggle">Disable Pager</button> <button type="button">Destroy Pager</button>
158 <br><br>
159 <div class="pager">
160 Page: <select class="gotoPage"></select>
161 <img src="../addons/pager/icons/first.png" class="first" alt="First" title="First page" />
162 <img src="../addons/pager/icons/prev.png" class="prev" alt="Prev" title="Previous page" />
163 <span class="pagedisplay"></span> <!-- this can be any element, including an input -->
164 <img src="../addons/pager/icons/next.png" class="next" alt="Next" title="Next page" />
165 <img src="../addons/pager/icons/last.png" class="last" alt="Last" title= "Last page" />
166 <select class="pagesize">
167 <option value="10">10</option>
168 <option value="20">20</option>
169 <option value="30">30</option>
170 <option value="40">40</option>
171 </select>
172 </div>
173
174 <table class="tablesorter">
175 <thead>
176 <tr>
177 <th>Name</th>
178 <th>Major</th>
179 <th>Sex</th>
180 <th>English</th>
181 <th>Japanese</th>
182 <th>Calculus</th>
183 <th>Geometry</th>
184 <th class="filter-false remove sorter-false"></th>
185 </tr>
186 </thead>
187 <tfoot>
188 <tr>
189 <th>Name</th>
190 <th>Major</th>
191 <th>Sex</th>
192 <th>English</th>
193 <th>Japanese</th>
194 <th>Calculus</th>
195 <th>Geometry</th>
196 <th></th>
197 </tr>
198 </tfoot>
199 <tbody>
200 <tr>
201 <td>Student01</td>
202 <td>Languages</td>
203 <td>male</td>
204 <td>80</td>
205 <td>70</td>
206 <td>75</td>
207 <td>80</td>
208 <td><button type="button" class="remove" title="Remove this row">X</button></td>
209 </tr>
210 <tr>
211 <td>Student02</td>
212 <td>Mathematics</td>
213 <td>male</td>
214 <td>90</td>
215 <td>88</td>
216 <td>100</td>
217 <td>90</td>
218 <td><button type="button" class="remove" title="Remove this row">X</button></td>
219 </tr>
220 <tr>
221 <td>Student03</td>
222 <td>Languages</td>
223 <td>female</td>
224 <td>85</td>
225 <td>95</td>
226 <td>80</td>
227 <td>85</td>
228 <td><button type="button" class="remove" title="Remove this row">X</button></td>
229 </tr>
230 <tr>
231 <td>Student04</td>
232 <td>Languages</td>
233 <td>male</td>
234 <td>60</td>
235 <td>55</td>
236 <td>100</td>
237 <td>100</td>
238 <td><button type="button" class="remove" title="Remove this row">X</button></td>
239 </tr>
240 <tr>
241 <td>Student05</td>
242 <td>Languages</td>
243 <td>female</td>
244 <td>68</td>
245 <td>80</td>
246 <td>95</td>
247 <td>80</td>
248 <td><button type="button" class="remove" title="Remove this row">X</button></td>
249 </tr>
250 <tr>
251 <td>Student06</td>
252 <td>Mathematics</td>
253 <td>male</td>
254 <td>100</td>
255 <td>99</td>
256 <td>100</td>
257 <td>90</td>
258 <td><button type="button" class="remove" title="Remove this row">X</button></td>
259 </tr>
260 <tr>
261 <td>Student07</td>
262 <td>Mathematics</td>
263 <td>male</td>
264 <td>85</td>
265 <td>68</td>
266 <td>90</td>
267 <td>90</td>
268 <td><button type="button" class="remove" title="Remove this row">X</button></td>
269 </tr>
270 <tr>
271 <td>Student08</td>
272 <td>Languages</td>
273 <td>male</td>
274 <td>100</td>
275 <td>90</td>
276 <td>90</td>
277 <td>85</td>
278 <td><button type="button" class="remove" title="Remove this row">X</button></td>
279 </tr>
280 <tr>
281 <td>Student09</td>
282 <td>Mathematics</td>
283 <td>male</td>
284 <td>80</td>
285 <td>50</td>
286 <td>65</td>
287 <td>75</td>
288 <td><button type="button" class="remove" title="Remove this row">X</button></td>
289 </tr>
290 <tr>
291 <td>Student10</td>
292 <td>Languages</td>
293 <td>male</td>
294 <td>85</td>
295 <td>100</td>
296 <td>100</td>
297 <td>90</td>
298 <td><button type="button" class="remove" title="Remove this row">X</button></td>
299 </tr>
300 <tr>
301 <td>Student11</td>
302 <td>Languages</td>
303 <td>male</td>
304 <td>86</td>
305 <td>85</td>
306 <td>100</td>
307 <td>100</td>
308 <td><button type="button" class="remove" title="Remove this row">X</button></td>
309 </tr>
310 <tr>
311 <td>Student12</td>
312 <td>Mathematics</td>
313 <td>female</td>
314 <td>100</td>
315 <td>75</td>
316 <td>70</td>
317 <td>85</td>
318 <td><button type="button" class="remove" title="Remove this row">X</button></td>
319 </tr>
320 <tr>
321 <td>Student13</td>
322 <td>Languages</td>
323 <td>female</td>
324 <td>100</td>
325 <td>80</td>
326 <td>100</td>
327 <td>90</td>
328 <td><button type="button" class="remove" title="Remove this row">X</button></td>
329 </tr>
330 <tr>
331 <td>Student14</td>
332 <td>Languages</td>
333 <td>female</td>
334 <td>50</td>
335 <td>45</td>
336 <td>55</td>
337 <td>90</td>
338 <td><button type="button" class="remove" title="Remove this row">X</button></td>
339 </tr>
340 <tr>
341 <td>Student15</td>
342 <td>Languages</td>
343 <td>male</td>
344 <td>95</td>
345 <td>35</td>
346 <td>100</td>
347 <td>90</td>
348 <td><button type="button" class="remove" title="Remove this row">X</button></td>
349 </tr>
350 <tr>
351 <td>Student16</td>
352 <td>Languages</td>
353 <td>female</td>
354 <td>100</td>
355 <td>50</td>
356 <td>30</td>
357 <td>70</td>
358 <td><button type="button" class="remove" title="Remove this row">X</button></td>
359 </tr>
360 <tr>
361 <td>Student17</td>
362 <td>Languages</td>
363 <td>female</td>
364 <td>80</td>
365 <td>100</td>
366 <td>55</td>
367 <td>65</td>
368 <td><button type="button" class="remove" title="Remove this row">X</button></td>
369 </tr>
370 <tr>
371 <td>Student18</td>
372 <td>Mathematics</td>
373 <td>male</td>
374 <td>30</td>
375 <td>49</td>
376 <td>55</td>
377 <td>75</td>
378 <td><button type="button" class="remove" title="Remove this row">X</button></td>
379 </tr>
380 <tr>
381 <td>Student19</td>
382 <td>Languages</td>
383 <td>male</td>
384 <td>68</td>
385 <td>90</td>
386 <td>88</td>
387 <td>70</td>
388 <td><button type="button" class="remove" title="Remove this row">X</button></td>
389 </tr>
390 <tr>
391 <td>Student20</td>
392 <td>Mathematics</td>
393 <td>male</td>
394 <td>40</td>
395 <td>45</td>
396 <td>40</td>
397 <td>80</td>
398 <td><button type="button" class="remove" title="Remove this row">X</button></td>
399 </tr>
400 <tr>
401 <td>Student21</td>
402 <td>Languages</td>
403 <td>male</td>
404 <td>50</td>
405 <td>45</td>
406 <td>100</td>
407 <td>100</td>
408 <td><button type="button" class="remove" title="Remove this row">X</button></td>
409 </tr>
410 <tr>
411 <td>Student22</td>
412 <td>Mathematics</td>
413 <td>male</td>
414 <td>100</td>
415 <td>99</td>
416 <td>100</td>
417 <td>90</td>
418 <td><button type="button" class="remove" title="Remove this row">X</button></td>
419 </tr>
420 <tr><td>Student23</td><td>Mathematics</td><td>male</td><td>82</td><td>77</td><td>0</td><td>79</td><td><button type="button" class="remove" title="Remove this row">X</button></td></tr>
421 <tr><td>Student24</td><td>Languages</td><td>female</td><td>100</td><td>91</td><td>13</td><td>82</td><td><button type="button" class="remove" title="Remove this row">X</button></td></tr>
422 <tr><td>Student25</td><td>Mathematics</td><td>male</td><td>22</td><td>96</td><td>82</td><td>53</td><td><button type="button" class="remove" title="Remove this row">X</button></td></tr>
423 <tr><td>Student26</td><td>Languages</td><td>female</td><td>37</td><td>29</td><td>56</td><td>59</td><td><button type="button" class="remove" title="Remove this row">X</button></td></tr>
424 <tr><td>Student27</td><td>Mathematics</td><td>male</td><td>86</td><td>82</td><td>69</td><td>23</td><td><button type="button" class="remove" title="Remove this row">X</button></td></tr>
425 <tr><td>Student28</td><td>Languages</td><td>female</td><td>44</td><td>25</td><td>43</td><td>1</td><td><button type="button" class="remove" title="Remove this row">X</button></td></tr>
426 <tr><td>Student29</td><td>Mathematics</td><td>male</td><td>77</td><td>47</td><td>22</td><td>38</td><td><button type="button" class="remove" title="Remove this row">X</button></td></tr>
427 <tr><td>Student30</td><td>Languages</td><td>female</td><td>19</td><td>35</td><td>23</td><td>10</td><td><button type="button" class="remove" title="Remove this row">X</button></td></tr>
428 <tr><td>Student31</td><td>Mathematics</td><td>male</td><td>90</td><td>27</td><td>17</td><td>50</td><td><button type="button" class="remove" title="Remove this row">X</button></td></tr>
429 <tr><td>Student32</td><td>Languages</td><td>female</td><td>60</td><td>75</td><td>33</td><td>38</td><td><button type="button" class="remove" title="Remove this row">X</button></td></tr>
430 <tr><td>Student33</td><td>Mathematics</td><td>male</td><td>4</td><td>31</td><td>37</td><td>15</td><td><button type="button" class="remove" title="Remove this row">X</button></td></tr>
431 <tr><td>Student34</td><td>Languages</td><td>female</td><td>77</td><td>97</td><td>81</td><td>44</td><td><button type="button" class="remove" title="Remove this row">X</button></td></tr>
432 <tr><td>Student35</td><td>Mathematics</td><td>male</td><td>5</td><td>81</td><td>51</td><td>95</td><td><button type="button" class="remove" title="Remove this row">X</button></td></tr>
433 <tr><td>Student36</td><td>Languages</td><td>female</td><td>70</td><td>61</td><td>70</td><td>94</td><td><button type="button" class="remove" title="Remove this row">X</button></td></tr>
434 <tr><td>Student37</td><td>Mathematics</td><td>male</td><td>60</td><td>3</td><td>61</td><td>84</td><td><button type="button" class="remove" title="Remove this row">X</button></td></tr>
435 <tr><td>Student38</td><td>Languages</td><td>female</td><td>63</td><td>39</td><td>0</td><td>11</td><td><button type="button" class="remove" title="Remove this row">X</button></td></tr>
436 <tr><td>Student39</td><td>Mathematics</td><td>male</td><td>50</td><td>46</td><td>32</td><td>38</td><td><button type="button" class="remove" title="Remove this row">X</button></td></tr>
437 <tr><td>Student40</td><td>Languages</td><td>female</td><td>51</td><td>75</td><td>25</td><td>3</td><td><button type="button" class="remove" title="Remove this row">X</button></td></tr>
438 <tr><td>Student41</td><td>Mathematics</td><td>male</td><td>43</td><td>34</td><td>28</td><td>78</td><td><button type="button" class="remove" title="Remove this row">X</button></td></tr>
439 <tr><td>Student42</td><td>Languages</td><td>female</td><td>11</td><td>89</td><td>60</td><td>95</td><td><button type="button" class="remove" title="Remove this row">X</button></td></tr>
440 <tr><td>Student43</td><td>Mathematics</td><td>male</td><td>48</td><td>92</td><td>18</td><td>88</td><td><button type="button" class="remove" title="Remove this row">X</button></td></tr>
441 <tr><td>Student44</td><td>Languages</td><td>female</td><td>82</td><td>2</td><td>59</td><td>73</td><td><button type="button" class="remove" title="Remove this row">X</button></td></tr>
442 <tr><td>Student45</td><td>Mathematics</td><td>male</td><td>91</td><td>73</td><td>37</td><td>39</td><td><button type="button" class="remove" title="Remove this row">X</button></td></tr>
443 <tr><td>Student46</td><td>Languages</td><td>female</td><td>4</td><td>8</td><td>12</td><td>10</td><td><button type="button" class="remove" title="Remove this row">X</button></td></tr>
444 <tr><td>Student47</td><td>Mathematics</td><td>male</td><td>89</td><td>10</td><td>6</td><td>11</td><td><button type="button" class="remove" title="Remove this row">X</button></td></tr>
445 <tr><td>Student48</td><td>Languages</td><td>female</td><td>90</td><td>32</td><td>21</td><td>18</td><td><button type="button" class="remove" title="Remove this row">X</button></td></tr>
446 <tr><td>Student49</td><td>Mathematics</td><td>male</td><td>42</td><td>49</td><td>49</td><td>72</td><td><button type="button" class="remove" title="Remove this row">X</button></td></tr>
447 <tr><td>Student50</td><td>Languages</td><td>female</td><td>56</td><td>37</td><td>67</td><td>54</td><td><button type="button" class="remove" title="Remove this row">X</button></td></tr>
448 </tbody>
449 </table>
450
451 <div class="pager">
452 Page: <select class="gotoPage"></select> <img src="../addons/pager/icons/first.png" class="first" alt="First" title="First page" />
453 <img src="../addons/pager/icons/prev.png" class="prev" alt="Prev" title="Previous page" />
454 <span class="pagedisplay"></span> <!-- this can be any element, including an input -->
455 <img src="../addons/pager/icons/next.png" class="next" alt="Next" title="Next page" />
456 <img src="../addons/pager/icons/last.png" class="last" alt="Last" title= "Last page" />
457 <select class="pagesize">
458 <option value="10">10</option>
459 <option value="20">20</option>
460 <option value="30">30</option>
461 <option value="40">40</option>
462 </select>
463 </div>
464
465 <h1>Javascript</h1>
466 <div id="javascript">
467 <pre class="prettyprint lang-javascript"></pre>
468 </div>
469
470 <div class="next-up">
471 <hr />
472 Next up: <a href="example-empty-table.html">Initializing tablesorter on a empty table &rsaquo;&rsaquo;</a>
473 </div>
474
475 </div>
476
477 </body>
478 </html>