| 1 |
<!DOCTYPE html> |
| 2 |
<html> |
| 3 |
<head> |
| 4 |
<meta charset="utf-8"> |
| 5 |
<title>jQuery tablesorter 2.0 - Bootstrap Theme (Bootstrap v2.x)</title> |
| 6 |
|
| 7 |
|
| 8 |
<script src="js/jquery-1.4.4.min.js"></script> |
| 9 |
|
| 10 |
|
| 11 |
<link rel="stylesheet" href="css/jq.css"> |
| 12 |
<link rel="stylesheet" href="css/bootstrap-v2.min.css"> |
| 13 |
<link href="css/prettify.css" rel="stylesheet"> |
| 14 |
<script src="js/prettify.js"></script> |
| 15 |
<script src="js/docs.js"></script> |
| 16 |
|
| 17 |
|
| 18 |
<link rel="stylesheet" href="../css/theme.bootstrap_2.css"> |
| 19 |
<script src="../js/jquery.tablesorter.js"></script> |
| 20 |
<script src="../js/jquery.tablesorter.widgets.js"></script> |
| 21 |
|
| 22 |
|
| 23 |
<link rel="stylesheet" href="../addons/pager/jquery.tablesorter.pager.css"> |
| 24 |
<script src="../addons/pager/jquery.tablesorter.pager.js"></script> |
| 25 |
|
| 26 |
<script id="js">$(function() { |
| 27 |
|
| 28 |
// NOTE: $.tablesorter.themes.bootstrap is ALREADY INCLUDED in the jquery.tablesorter.widgets.js |
| 29 |
// file for Bootstrap v3.x; it is included here because of class name differences in Bootstrap v2 |
| 30 |
// for version 2.x (the iconSortAsc & iconSortDesc use different classes) |
| 31 |
$.tablesorter.themes.bootstrap = { |
| 32 |
// these classes are added to the table. To see other table classes available, |
| 33 |
// look here: http://getbootstrap.com/css/#tables |
| 34 |
table : 'table table-bordered table-striped', |
| 35 |
caption : 'caption', |
| 36 |
// header class names |
| 37 |
header : 'bootstrap-header', // give the header a gradient background (theme.bootstrap_2.css) |
| 38 |
sortNone : '', |
| 39 |
sortAsc : '', |
| 40 |
sortDesc : '', |
| 41 |
active : '', // applied when column is sorted |
| 42 |
hover : '', // custom css required - a defined bootstrap style may not override other classes |
| 43 |
// icon class names |
| 44 |
icons : '', // add "icon-white" to make them white; this icon class is added to the <i> in the header |
| 45 |
iconSortNone : 'bootstrap-icon-unsorted', // class name added to icon when column is not sorted |
| 46 |
iconSortAsc : 'icon-chevron-up', // class name added to icon when column has ascending sort |
| 47 |
iconSortDesc : 'icon-chevron-down', // class name added to icon when column has descending sort |
| 48 |
filterRow : '', // filter row class |
| 49 |
footerRow : '', |
| 50 |
footerCells : '', |
| 51 |
even : '', // even row zebra striping |
| 52 |
odd : '' // odd row zebra striping |
| 53 |
}; |
| 54 |
|
| 55 |
// call the tablesorter plugin and apply the uitheme widget |
| 56 |
$("table").tablesorter({ |
| 57 |
// this will apply the bootstrap theme if "uitheme" widget is included |
| 58 |
// the widgetOptions.uitheme is no longer required to be set |
| 59 |
theme : "bootstrap", // version 2!! |
| 60 |
|
| 61 |
widthFixed: true, |
| 62 |
|
| 63 |
headerTemplate : '{content} {icon}', // new in v2.7. Needed to add the bootstrap icon! |
| 64 |
|
| 65 |
// widget code contained in the jquery.tablesorter.widgets.js file |
| 66 |
// use the zebra stripe widget if you plan on hiding any rows (filter widget) |
| 67 |
widgets : [ "uitheme", "filter", "columns", "zebra" ], |
| 68 |
|
| 69 |
widgetOptions : { |
| 70 |
// using the default zebra striping class name, so it actually isn't included in the theme variable above |
| 71 |
// this is ONLY needed for bootstrap theming if you are using the filter widget, because rows are hidden |
| 72 |
zebra : ["even", "odd"], |
| 73 |
|
| 74 |
// class names added to columns when sorted |
| 75 |
columns: [ "primary", "secondary", "tertiary" ], |
| 76 |
|
| 77 |
// reset filters button |
| 78 |
filter_reset : ".reset", |
| 79 |
|
| 80 |
// hide the filter row when not active |
| 81 |
filter_hideFilters : true |
| 82 |
|
| 83 |
} |
| 84 |
}) |
| 85 |
.tablesorterPager({ |
| 86 |
|
| 87 |
// target the pager markup - see the HTML block below |
| 88 |
container: $(".ts-pager"), |
| 89 |
|
| 90 |
// target the pager page select dropdown - choose a page |
| 91 |
cssGoto : ".pagenum", |
| 92 |
|
| 93 |
// remove rows from the table to speed up the sort of large tables. |
| 94 |
// setting this to false, only hides the non-visible rows; needed if you plan to add/remove rows with the pager enabled. |
| 95 |
removeRows: false, |
| 96 |
|
| 97 |
// output string - default is '{page}/{totalPages}'; |
| 98 |
// possible variables: {page}, {totalPages}, {filteredPages}, {startRow}, {endRow}, {filteredRows} and {totalRows} |
| 99 |
output: '{startRow} - {endRow} / {filteredRows} ({totalRows})' |
| 100 |
|
| 101 |
}); |
| 102 |
|
| 103 |
});</script> |
| 104 |
|
| 105 |
<script> |
| 106 |
$(function() { |
| 107 |
|
| 108 |
// filter button demo code |
| 109 |
$('button.filter').click(function() { |
| 110 |
var col = $(this).data('column'), |
| 111 |
txt = $(this).data('filter'); |
| 112 |
$('table').find('.tablesorter-filter').val('').eq(col).val(txt); |
| 113 |
$('table').trigger('search', false); |
| 114 |
return false; |
| 115 |
}); |
| 116 |
|
| 117 |
// toggle zebra widget |
| 118 |
$('button.zebra').click(function() { |
| 119 |
var t = $(this).hasClass('btn-success'); |
| 120 |
// if (t) { |
| 121 |
// removing classes applied by the zebra widget |
| 122 |
// you shouldn't ever need to use this code, it is only for this demo |
| 123 |
// $('table').find('tr').removeClass('odd even'); |
| 124 |
// } |
| 125 |
$('table') |
| 126 |
.toggleClass('table-striped')[0] |
| 127 |
.config.widgets = (t) ? ["uitheme", "filter"] : ["uitheme", "filter", "zebra"]; |
| 128 |
$(this) |
| 129 |
.toggleClass('btn-danger btn-success') |
| 130 |
.find('i') |
| 131 |
.toggleClass('icon-ok icon-remove').end() |
| 132 |
.find('span') |
| 133 |
.text(t ? 'disabled' : 'enabled'); |
| 134 |
$('table').trigger('refreshWidgets', [false]); |
| 135 |
return false; |
| 136 |
}); |
| 137 |
}); |
| 138 |
</script> |
| 139 |
|
| 140 |
</head> |
| 141 |
<body> |
| 142 |
|
| 143 |
<div id="banner"> |
| 144 |
<h1>table<em>sorter</em></h1> |
| 145 |
<h2>Bootstrap v2.x Theme (requires UITheme Widget)</h2> |
| 146 |
<h3>Flexible client-side table sorting</h3> |
| 147 |
<a href="index.html">Back to documentation</a> |
| 148 |
</div> |
| 149 |
|
| 150 |
<div id="main"> |
| 151 |
|
| 152 |
<p class="tip"> |
| 153 |
<span class="label label-info">NOTE!</span> |
| 154 |
</p> |
| 155 |
<ul> |
| 156 |
<li>Go to <a href="example-option-theme-bootstrap-v4.html">Bootstrap v4.x</a> or <a href="example-option-theme-bootstrap-v3.html">Bootstrap v3.x</a> demo.<br><br></li> |
| 157 |
<li>In <span class="version updated">v2.28.4</span>, added support for the column widget.</li> |
| 158 |
<li>This demo uses <a href="http://getbootstrap.com/2.3.2/">Bootstrap v2.x</a> (v2.3.2 specifically).</li> |
| 159 |
<li>Hover over the thick grey bar under the header to reveal the filter row.</li> |
| 160 |
<li>For more information like revision history of this theme & why there is a button to enable/disable the zebra widget, please see the <a href="example-option-theme-bootstrap-v3.html">Bootstrap v3.x demo</a>.</li> |
| 161 |
</ul> |
| 162 |
|
| 163 |
<h1>Demo</h1> |
| 164 |
|
| 165 |
<div class="bootstrap_buttons"> |
| 166 |
Reset filter : <button type="button" class="reset btn btn-primary" data-column="0" data-filter=""><i class="icon-white icon-refresh"></i> Reset filters</button> |
| 167 |
<br> |
| 168 |
Zebra widget : <button type="button" class="zebra btn btn-success"><i class="icon-white icon-ok"></i> <span>enabled</span></button> |
| 169 |
</div> |
| 170 |
<br> |
| 171 |
|
| 172 |
<div id="demo"><table> |
| 173 |
<thead> |
| 174 |
<tr> |
| 175 |
<th>Name</th> |
| 176 |
<th>Major</th> |
| 177 |
<th class="filter-select filter-exact" data-placeholder="Pick a gender">Sex</th> |
| 178 |
<th>English</th> |
| 179 |
<th>Japanese</th> |
| 180 |
<th>Calculus</th> |
| 181 |
<th>Geometry</th></tr> |
| 182 |
</thead> |
| 183 |
<tfoot> |
| 184 |
<tr> |
| 185 |
<th>Name</th> |
| 186 |
<th>Major</th> |
| 187 |
<th>Sex</th> |
| 188 |
<th>English</th> |
| 189 |
<th>Japanese</th> |
| 190 |
<th>Calculus</th> |
| 191 |
<th>Geometry</th> |
| 192 |
</tr> |
| 193 |
<tr> |
| 194 |
<th colspan="7" class="ts-pager form-horizontal"> |
| 195 |
<div class="btn-group"> |
| 196 |
<button type="button" class="btn first"><i class="icon-step-backward"></i></button> |
| 197 |
<button type="button" class="btn prev"><i class="icon-arrow-left"></i></button> |
| 198 |
</div> |
| 199 |
<span class="pagedisplay"></span> |
| 200 |
<div class="btn-group"> |
| 201 |
<button type="button" class="btn next"><i class="icon-arrow-right"></i></button> |
| 202 |
<button type="button" class="btn last"><i class="icon-step-forward"></i></button> |
| 203 |
</div> |
| 204 |
<select class="pagesize input-mini" title="Select page size"> |
| 205 |
<option selected="selected" value="10">10</option> |
| 206 |
<option value="20">20</option> |
| 207 |
<option value="30">30</option> |
| 208 |
<option value="all">All Rows</option> |
| 209 |
</select> |
| 210 |
<select class="pagenum input-mini" title="Select page number"></select> |
| 211 |
</th> |
| 212 |
</tr> |
| 213 |
</tfoot> |
| 214 |
<tbody> |
| 215 |
<tr><td>Student01</td><td>Languages</td><td>male</td><td>80</td><td>70</td><td>75</td><td>80</td></tr> |
| 216 |
<tr><td>Student02</td><td>Mathematics</td><td>male</td><td>90</td><td>88</td><td>100</td><td>90</td></tr> |
| 217 |
<tr><td>Student03</td><td>Languages</td><td>female</td><td>85</td><td>95</td><td>80</td><td>85</td></tr> |
| 218 |
<tr><td>Student04</td><td>Languages</td><td>male</td><td>60</td><td>55</td><td>100</td><td>100</td></tr> |
| 219 |
<tr><td>Student05</td><td>Languages</td><td>female</td><td>68</td><td>80</td><td>95</td><td>80</td></tr> |
| 220 |
<tr><td>Student06</td><td>Mathematics</td><td>male</td><td>100</td><td>99</td><td>100</td><td>90</td></tr> |
| 221 |
<tr><td>Student07</td><td>Mathematics</td><td>male</td><td>85</td><td>68</td><td>90</td><td>90</td></tr> |
| 222 |
<tr><td>Student08</td><td>Languages</td><td>male</td><td>100</td><td>90</td><td>90</td><td>85</td></tr> |
| 223 |
<tr><td>Student09</td><td>Mathematics</td><td>male</td><td>80</td><td>50</td><td>65</td><td>75</td></tr> |
| 224 |
<tr><td>Student10</td><td>Languages</td><td>male</td><td>85</td><td>100</td><td>100</td><td>90</td></tr> |
| 225 |
<tr><td>Student11</td><td>Languages</td><td>male</td><td>86</td><td>85</td><td>100</td><td>100</td></tr> |
| 226 |
<tr><td>Student12</td><td>Mathematics</td><td>female</td><td>100</td><td>75</td><td>70</td><td>85</td></tr> |
| 227 |
<tr><td>Student13</td><td>Languages</td><td>female</td><td>100</td><td>80</td><td>100</td><td>90</td></tr> |
| 228 |
<tr><td>Student14</td><td>Languages</td><td>female</td><td>50</td><td>45</td><td>55</td><td>90</td></tr> |
| 229 |
<tr><td>Student15</td><td>Languages</td><td>male</td><td>95</td><td>35</td><td>100</td><td>90</td></tr> |
| 230 |
<tr><td>Student16</td><td>Languages</td><td>female</td><td>100</td><td>50</td><td>30</td><td>70</td></tr> |
| 231 |
<tr><td>Student17</td><td>Languages</td><td>female</td><td>80</td><td>100</td><td>55</td><td>65</td></tr> |
| 232 |
<tr><td>Student18</td><td>Mathematics</td><td>male</td><td>30</td><td>49</td><td>55</td><td>75</td></tr> |
| 233 |
<tr><td>Student19</td><td>Languages</td><td>male</td><td>68</td><td>90</td><td>88</td><td>70</td></tr> |
| 234 |
<tr><td>Student20</td><td>Mathematics</td><td>male</td><td>40</td><td>45</td><td>40</td><td>80</td></tr> |
| 235 |
<tr><td>Student21</td><td>Languages</td><td>male</td><td>50</td><td>45</td><td>100</td><td>100</td></tr> |
| 236 |
<tr><td>Student22</td><td>Mathematics</td><td>male</td><td>100</td><td>99</td><td>100</td><td>90</td></tr> |
| 237 |
<tr><td>Student23</td><td>Mathematics</td><td>male</td><td>82</td><td>77</td><td>0</td><td>79</td></tr> |
| 238 |
<tr><td>Student24</td><td>Languages</td><td>female</td><td>100</td><td>91</td><td>13</td><td>82</td></tr> |
| 239 |
<tr><td>Student25</td><td>Mathematics</td><td>male</td><td>22</td><td>96</td><td>82</td><td>53</td></tr> |
| 240 |
<tr><td>Student26</td><td>Languages</td><td>female</td><td>37</td><td>29</td><td>56</td><td>59</td></tr> |
| 241 |
<tr><td>Student27</td><td>Mathematics</td><td>male</td><td>86</td><td>82</td><td>69</td><td>23</td></tr> |
| 242 |
<tr><td>Student28</td><td>Languages</td><td>female</td><td>44</td><td>25</td><td>43</td><td>1</td></tr> |
| 243 |
<tr><td>Student29</td><td>Mathematics</td><td>male</td><td>77</td><td>47</td><td>22</td><td>38</td></tr> |
| 244 |
<tr><td>Student30</td><td>Languages</td><td>female</td><td>19</td><td>35</td><td>23</td><td>10</td></tr> |
| 245 |
<tr><td>Student31</td><td>Mathematics</td><td>male</td><td>90</td><td>27</td><td>17</td><td>50</td></tr> |
| 246 |
<tr><td>Student32</td><td>Languages</td><td>female</td><td>60</td><td>75</td><td>33</td><td>38</td></tr> |
| 247 |
<tr><td>Student33</td><td>Mathematics</td><td>male</td><td>4</td><td>31</td><td>37</td><td>15</td></tr> |
| 248 |
<tr><td>Student34</td><td>Languages</td><td>female</td><td>77</td><td>97</td><td>81</td><td>44</td></tr> |
| 249 |
<tr><td>Student35</td><td>Mathematics</td><td>male</td><td>5</td><td>81</td><td>51</td><td>95</td></tr> |
| 250 |
<tr><td>Student36</td><td>Languages</td><td>female</td><td>70</td><td>61</td><td>70</td><td>94</td></tr> |
| 251 |
<tr><td>Student37</td><td>Mathematics</td><td>male</td><td>60</td><td>3</td><td>61</td><td>84</td></tr> |
| 252 |
<tr><td>Student38</td><td>Languages</td><td>female</td><td>63</td><td>39</td><td>0</td><td>11</td></tr> |
| 253 |
<tr><td>Student39</td><td>Mathematics</td><td>male</td><td>50</td><td>46</td><td>32</td><td>38</td></tr> |
| 254 |
<tr><td>Student40</td><td>Languages</td><td>female</td><td>51</td><td>75</td><td>25</td><td>3</td></tr> |
| 255 |
<tr><td>Student41</td><td>Mathematics</td><td>male</td><td>43</td><td>34</td><td>28</td><td>78</td></tr> |
| 256 |
<tr><td>Student42</td><td>Languages</td><td>female</td><td>11</td><td>89</td><td>60</td><td>95</td></tr> |
| 257 |
<tr><td>Student43</td><td>Mathematics</td><td>male</td><td>48</td><td>92</td><td>18</td><td>88</td></tr> |
| 258 |
<tr><td>Student44</td><td>Languages</td><td>female</td><td>82</td><td>2</td><td>59</td><td>73</td></tr> |
| 259 |
<tr><td>Student45</td><td>Mathematics</td><td>male</td><td>91</td><td>73</td><td>37</td><td>39</td></tr> |
| 260 |
<tr><td>Student46</td><td>Languages</td><td>female</td><td>4</td><td>8</td><td>12</td><td>10</td></tr> |
| 261 |
<tr><td>Student47</td><td>Mathematics</td><td>male</td><td>89</td><td>10</td><td>6</td><td>11</td></tr> |
| 262 |
<tr><td>Student48</td><td>Languages</td><td>female</td><td>90</td><td>32</td><td>21</td><td>18</td></tr> |
| 263 |
<tr><td>Student49</td><td>Mathematics</td><td>male</td><td>42</td><td>49</td><td>49</td><td>72</td></tr> |
| 264 |
<tr><td>Student50</td><td>Languages</td><td>female</td><td>56</td><td>37</td><td>67</td><td>54</td></tr> |
| 265 |
</tbody> |
| 266 |
</table></div> |
| 267 |
|
| 268 |
<h2>Page Header</h2> |
| 269 |
<div> |
| 270 |
<pre class="prettyprint lang-html"><!-- Bootstrap stylesheet --> |
| 271 |
<link rel="stylesheet" href="css/bootstrap-v2.min.css"> |
| 272 |
<!-- bootstrap widget theme --> |
| 273 |
<link rel="stylesheet" href="css/theme.bootstrap_2.css"> |
| 274 |
|
| 275 |
<!-- load jQuery first --> |
| 276 |
<script src="js/jquery.min.js"></script> |
| 277 |
|
| 278 |
<!-- tablesorter plugin --> |
| 279 |
<script src="js/jquery.tablesorter.js"></script> |
| 280 |
<!-- tablesorter widget file - loaded after the plugin --> |
| 281 |
<script src="js/jquery.tablesorter.widgets.js"></script> |
| 282 |
|
| 283 |
<!-- pager plugin --> |
| 284 |
<link rel="stylesheet" href="css/jquery.tablesorter.pager.css"> |
| 285 |
<script src="js/jquery.tablesorter.pager.js"></script></pre> |
| 286 |
</div> |
| 287 |
|
| 288 |
<h2>Javascript</h2> |
| 289 |
<div id="javascript"> |
| 290 |
<pre class="prettyprint lang-javascript"></pre> |
| 291 |
</div> |
| 292 |
|
| 293 |
<h2>HTML</h2> |
| 294 |
<div id="html"> |
| 295 |
<pre class="prettyprint lang-html"></pre> |
| 296 |
</div> |
| 297 |
|
| 298 |
<div class="next-up"> |
| 299 |
<hr /> |
| 300 |
Next up: <a href="example-widget-vertical-group.html">Vertical group widget ››</a> |
| 301 |
</div> |
| 302 |
|
| 303 |
</div> |
| 304 |
|
| 305 |
</body> |
| 306 |
</html> |