tablesorter/docs/example-option-text-extraction.html
2011-08-19 01:24:29 -05:00

135 lines
3.2 KiB
HTML

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>jQuery plugin: Tablesorter 2.0 - Dealing with markup inside cells</title>
<!-- jQuery -->
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.6/jquery.min.js"></script>
<!-- Demo stuff -->
<link rel="stylesheet" href="css/jq.css">
<script src="js/chili/jquery.chili-2.2.js"></script>
<script src="js/chili/recipes.js"></script>
<script src="js/docs.js"></script>
<!-- Tablesorter: required -->
<link rel="stylesheet" href="../css/blue/style.css">
<script src="../js/jquery.tablesorter.js"></script>
<script id="js">$(function() {
// call the tablesorter plugin
$("table").tablesorter({
/*
// define an overall custom text extraction function
textExtraction: function(node) {
return $(node).text();
}
*/
// define a custom text extraction function for each column
textExtraction: {
0: function(node) { return $(node).find("strong").text(); },
1: function(node) { return $(node).find("div").text(); },
2: function(node) { return $(node).find("span").text(); },
3: function(node) { return $(node).find("em").text(); },
4: function(node) { return $(node).find("a").text(); },
5: function(node) { return $(node).find("u").text(); }
}
});
});</script>
</head>
<body>
<div id="banner">
<h1>table<strong>sorter</strong></h1>
<h2>Dealing with markup inside cells</h2>
<h3>Flexible client-side table sorting</h3>
<a href="index.html">Back to documentation</a>
</div>
<div id="main">
<p class="tip">
<em>NOTE!</em> The "First Name" column is sorting by the contents of the &lt;strong&gt; tag (in red).
</p>
<h1>Demo</h1>
<div id="demo"><table class="tablesorter">
<thead>
<tr>
<th>First Name</th>
<th>Last Name</th>
<th>Age</th>
<th>Total</th>
<th>Discount</th>
<th>Date</th>
</tr>
</thead>
<tbody>
<tr>
<td>Mr. <strong>Peter</strong></td>
<td><div>Parker</div></td>
<td><span>28</span></td>
<td><em>$9.99</em></td>
<td><a href="#">20%</a></td>
<td><u>Jul 6, 2006 8:14 AM</u></td>
</tr>
<tr>
<td>Dr. <strong>John</strong></td>
<td><div>Hood</div></td>
<td><span>33</span></td>
<td><em>$19.99</em></td>
<td><a href="#">25%</a></td>
<td><u>Dec 10, 2002 5:14 AM</u></td>
</tr>
<tr>
<td>Rep <strong>Clark</strong></td>
<td><div>Kent</div></td>
<td><span>18</span></td>
<td><em>$15.89</em></td>
<td><a href="#">44%</a></td>
<td><u>Jan 12, 2003 11:14 AM</u></td>
</tr>
<tr>
<td>Rev <strong>Bruce</strong></td>
<td><div>Almighty</div></td>
<td><span>45</span></td>
<td><em>$153.19</em></td>
<td><a href="#">44%</a></td>
<td><u>Jan 18, 2001 9:12 AM</u></td>
</tr>
<tr>
<td>Capt <strong>Bruce</strong></td>
<td><div>Evans</div></td>
<td><span>22</span></td>
<td><em>$13.19</em></td>
<td><a href="#">11%</a></td>
<td><u>Jan 18, 2007 9:12 AM</u></td>
</tr>
</tbody>
</table></div>
<h1>Javascript</h1>
<div id="javascript">
<pre class="js"></pre>
</div>
<h1>HTML</h1>
<div id="html">
<pre class="html"></pre>
</div>
<div class="next-up">
<hr />
Next up: <a href="example-option-render-header.html">Advanced: Modify how the header is rendered to allow for custom styling &rsaquo;&rsaquo;</a>
</div>
</div>
</body>
</html>