1
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
2
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
3
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-us">
5
<title>jQuery plugin: Tablesorter 2.0 - Writing custom parsers</title>
6
<link rel="stylesheet" href="css/jq.css" type="text/css" media="print, projection, screen" />
7
<link rel="stylesheet" href="../themes/blue/style.css" type="text/css" media="print, projection, screen" />
8
<script type="text/javascript" src="../jquery-latest.js"></script>
10
<script type="text/javascript" src="../jquery.tablesorter.js"></script>
11
<script type="text/javascript" src="../addons/pager/jquery.tablesorter.pager.js"></script>
12
<script type="text/javascript" src="js/chili/chili-1.8b.js"></script>
13
<script type="text/javascript" src="js/docs.js"></script>
14
<script type="text/javascript" src="js/examples.js"></script>
15
<script type="text/javascript" id="js">
16
// add parser through the tablesorter addParser method
17
$.tablesorter.addParser({
21
// return false so this parser is not auto detected
25
// format your data for normalization
26
return s.toLowerCase().replace(/good/,2).replace(/medium/,1).replace(/bad/,0);
28
// set type, either numeric or text
33
$("table").tablesorter({
45
<h1>table<em>sorter</em></h1>
46
<h2>Writing custom parsers</h2>
47
<h3>Flexible client-side table sorting</h3>
48
<a href="index.html">Back to documentation</a>
53
<table cellspacing="1" class="tablesorter">
62
<th>Overall grades</th>
98
<pre class="javascript"></pre>
102
<pre class="html"></pre>
105
<script src="http://www.google-analytics.com/urchin.js" type="text/javascript"></script>
106
<script type="text/javascript">
107
_uacct = "UA-2189649-2";