| 1 |
<!DOCTYPE html> |
| 2 |
<html> |
| 3 |
<head> |
| 4 |
<meta charset="utf-8"> |
| 5 |
<title>jQuery tablesorter 2.0 - Columns Style Widget</title> |
| 6 |
|
| 7 |
|
| 8 |
<script src="js/jquery-1.2.6.min.js"></script> |
| 9 |
|
| 10 |
|
| 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 |
|
| 17 |
<link rel="stylesheet" href="../css/theme.default.css"> |
| 18 |
<link rel="stylesheet" href="../css/theme.blue.css"> |
| 19 |
<link rel="stylesheet" href="../css/theme.green.css"> |
| 20 |
<link rel="stylesheet" href="../css/theme.grey.css"> |
| 21 |
<link rel="stylesheet" href="../css/theme.ice.css"> |
| 22 |
<link rel="stylesheet" href="../css/theme.black-ice.css"> |
| 23 |
<link rel="stylesheet" href="../css/theme.dark.css"> |
| 24 |
<link rel="stylesheet" href="../css/theme.dropbox.css"> |
| 25 |
|
| 26 |
<script src="../js/jquery.tablesorter.js"></script> |
| 27 |
<script src="../js/jquery.tablesorter.widgets.js"></script> |
| 28 |
|
| 29 |
<script id="js">$(function() { |
| 30 |
|
| 31 |
// call the tablesorter plugin |
| 32 |
$("table").tablesorter({ |
| 33 |
theme : 'blue', |
| 34 |
|
| 35 |
sortList : [[1,0],[2,0],[3,0]], |
| 36 |
|
| 37 |
// header layout template; {icon} needed for some themes |
| 38 |
headerTemplate : '{content}{icon}', |
| 39 |
|
| 40 |
// initialize zebra striping and column styling of the table |
| 41 |
widgets : ["zebra", "columns"], |
| 42 |
|
| 43 |
widgetOptions : { |
| 44 |
// change the default column class names |
| 45 |
// primary is the first column sorted, secondary is the second, etc |
| 46 |
columns : [ "primary", "secondary", "tertiary" ], |
| 47 |
// include thead when adding class names |
| 48 |
columns_thead : true, |
| 49 |
// include tfoot when adding class names |
| 50 |
columns_tfoot : true |
| 51 |
} |
| 52 |
|
| 53 |
}); |
| 54 |
|
| 55 |
});</script> |
| 56 |
<script> |
| 57 |
$(function() { |
| 58 |
var themes = 'default blue green grey ice blackice dark dropbox', |
| 59 |
i, o = '', t = themes.split(' '); |
| 60 |
for (i = 0; i < t.length; i++) { |
| 61 |
o += '<option>' + t[i] + '</option>'; |
| 62 |
} |
| 63 |
$('select') |
| 64 |
.html(o) |
| 65 |
.change(function() { |
| 66 |
var theme = $(this).val().toLowerCase(); |
| 67 |
$('table') |
| 68 |
.removeClass('tablesorter-' + t.join(' tablesorter-')) |
| 69 |
.addClass('tablesorter-' + theme); |
| 70 |
}).trigger('change'); |
| 71 |
}); |
| 72 |
</script> |
| 73 |
</head> |
| 74 |
<body> |
| 75 |
<div id="banner"> |
| 76 |
<h1>table<em>sorter</em></h1> |
| 77 |
<h2>Columns Style Widget</h2> |
| 78 |
<h3>Flexible client-side table sorting</h3> |
| 79 |
<a href="index.html">Back to documentation</a> |
| 80 |
</div> |
| 81 |
<div id="main"> |
| 82 |
|
| 83 |
<p class="tip"> |
| 84 |
<em>NOTE!</em> |
| 85 |
</p> |
| 86 |
<ul> |
| 87 |
<li>As of tablesorter version 2.9+, this widget can no longer be applied to versions of tablesorter prior to version 2.8.</li> |
| 88 |
<li>Older versions of this widget can be applied to the original plugin. The code is in the "jquery.tablesorter.widgets.js" file.</li> |
| 89 |
<li>The original "widgetColumns" option has been replaced by "widgetOptions.columns". See the javascript block below for more details (v2.1).</li> |
| 90 |
<li>Table header and footer rows now get updated with the columns widget classes. Check out the "grey" theme to see (v2.4).</li> |
| 91 |
<li>This demo page is running jQuery v1.2.6.</li> |
| 92 |
</ul> |
| 93 |
|
| 94 |
<h1>Demo</h1> |
| 95 |
Choose Theme: |
| 96 |
<select></select> |
| 97 |
<br><br> |
| 98 |
|
| 99 |
<div id="demo"><table class="tablesorter"> |
| 100 |
<thead> |
| 101 |
<tr> |
| 102 |
<th>First Name</th> |
| 103 |
<th>Last Name</th> |
| 104 |
<th>Age</th> |
| 105 |
<th>Total</th> |
| 106 |
<th>Discount</th> |
| 107 |
<th>Date</th> |
| 108 |
</tr> |
| 109 |
</thead> |
| 110 |
<tfoot> |
| 111 |
<tr> |
| 112 |
<th>First Name</th> |
| 113 |
<th>Last Name</th> |
| 114 |
<th>Age</th> |
| 115 |
<th>Total</th> |
| 116 |
<th>Discount</th> |
| 117 |
<th>Date</th> |
| 118 |
</tr> |
| 119 |
</tfoot> |
| 120 |
<tbody> |
| 121 |
<tr> |
| 122 |
<td>Peter</td> |
| 123 |
<td>Parker</td> |
| 124 |
<td>28</td> |
| 125 |
<td>$9.99</td> |
| 126 |
<td>20%</td> |
| 127 |
<td>Jul 6, 2006 8:14 AM</td> |
| 128 |
</tr> |
| 129 |
<tr> |
| 130 |
<td>John</td> |
| 131 |
<td>Hood</td> |
| 132 |
<td>33</td> |
| 133 |
<td>$19.99</td> |
| 134 |
<td>25%</td> |
| 135 |
<td>Dec 10, 2002 5:14 AM</td> |
| 136 |
</tr> |
| 137 |
<tr> |
| 138 |
<td>Clark</td> |
| 139 |
<td>Kent</td> |
| 140 |
<td>18</td> |
| 141 |
<td>$15.89</td> |
| 142 |
<td>44%</td> |
| 143 |
<td>Jan 12, 2003 11:14 AM</td> |
| 144 |
</tr> |
| 145 |
<tr> |
| 146 |
<td>Bruce</td> |
| 147 |
<td>Almighty</td> |
| 148 |
<td>45</td> |
| 149 |
<td>$153.19</td> |
| 150 |
<td>44%</td> |
| 151 |
<td>Jan 18, 2001 9:12 AM</td> |
| 152 |
</tr> |
| 153 |
<tr> |
| 154 |
<td>Bruce</td> |
| 155 |
<td>Evans</td> |
| 156 |
<td>22</td> |
| 157 |
<td>$13.19</td> |
| 158 |
<td>11%</td> |
| 159 |
<td>Jan 18, 2007 9:12 AM</td> |
| 160 |
</tr> |
| 161 |
</tbody> |
| 162 |
</table></div> |
| 163 |
|
| 164 |
<h1>Page Header</h1> |
| 165 |
<div> |
| 166 |
<pre class="prettyprint lang-html"><!-- blue theme stylesheet with additional css styles added in v2.0.17 --> |
| 167 |
<link rel="stylesheet" href="../css/theme.blue.css"> |
| 168 |
<!-- tablesorter plugin --> |
| 169 |
<script src="../js/jquery.tablesorter.js"></script> |
| 170 |
|
| 171 |
<!-- tablesorter widget file - loaded after the plugin --> |
| 172 |
<script src="../js/jquery.tablesorter.widgets.js"></script></pre> |
| 173 |
</div> |
| 174 |
|
| 175 |
<h1>Javascript</h1> |
| 176 |
<div id="javascript"> |
| 177 |
<pre class="prettyprint lang-javascript"></pre> |
| 178 |
</div> |
| 179 |
|
| 180 |
<h1>CSS</h1> |
| 181 |
<div> |
| 182 |
<pre class="prettyprint lang-css">/* |
| 183 |
This css is part of the blue/style.css theme, shown as an example |
| 184 |
To work with the zebra widget, include the .odd and .even color definitions as well |
| 185 |
as definitions for the "primary", "secondary" and "tertiary" sorts. |
| 186 |
*/ |
| 187 |
/* Column Widget - column sort colors */ |
| 188 |
table.tablesorter-blue td.primary, |
| 189 |
table.tablesorter-blue tr.odd td.primary { |
| 190 |
background-color: #99b3e6; |
| 191 |
} |
| 192 |
table.tablesorter-blue tr.even td.primary { |
| 193 |
background-color: #c2d1f0; |
| 194 |
} |
| 195 |
|
| 196 |
table.tablesorter-blue td.secondary, |
| 197 |
table.tablesorter-blue tr.odd td.secondary { |
| 198 |
background-color: #c2d1f0; |
| 199 |
} |
| 200 |
table.tablesorter-blue tr.even td.secondary { |
| 201 |
background-color: #d6e0f5; |
| 202 |
} |
| 203 |
|
| 204 |
table.tablesorter-blue td.tertiary, |
| 205 |
table.tablesorter-blue tr.odd td.tertiary { |
| 206 |
background-color: #d6e0f5; |
| 207 |
} |
| 208 |
table.tablesorter-blue tr.even td.tertiary { |
| 209 |
background-color: #ebf0fa; |
| 210 |
}</pre> |
| 211 |
</div> |
| 212 |
|
| 213 |
<h1>HTML</h1> |
| 214 |
<div id="html"> |
| 215 |
<pre class="prettyprint lang-html"></pre> |
| 216 |
</div> |
| 217 |
|
| 218 |
<div class="next-up"> |
| 219 |
<hr /> |
| 220 |
Next up: <a href="example-widget-filter.html">Applying the filter widget ››</a> |
| 221 |
</div> |
| 222 |
|
| 223 |
</div> |
| 224 |
|
| 225 |
</body> |
| 226 |
</html> |