I am trying to use Jquery Table sorter plugin latest available. http://mottie.github.com/tablesorter/docs/#Demo
The issue is I have a table column with Date format and also it contains an email value. I am trying to extract the date value and sort it based on date value.
Since I am using latest version of Table sorter I tried to use the parser class name available in the latest(http://mottie.github.com/tablesorter/docs/example-parsers-class-name.html) .
Please find my fiddle below.
http://jsfiddle.net/meetravi/pztqe/8/
Code Snippet:
<tr>
<th>Name</th>
<th>Major</th>
<th>Sex</th>
<th>English</th>
<th>Japanese</th>
<th>Calculus</th>
<th>Geometry</th>
<th class="sorter-shortDate">Date</th>
</tr>
<tbody>
<tr>
<td>Student01</td>
<td>Languages</td>
<td>male</td>
<td>80</td>
<td>70</td>
<td>75</td>
<td>80</td>
<td><em>11/01/12 11:42</em><spanclass="label">xyz@xyz.com</span></td>
</tr>
</tbody>
<script type="text/javascript">
$(document).ready(function(){
$('#table-Id').tablesorter({
theme: 'blue',
dateFormat : "ddmmyy",
textExtraction: {
7: function(node, table, cellIndex) {
return $(node).find("em").text();
}
}
});
});
</script>
First off, there should be a space between the span and class.
Second, the date parser is only set up to work with 4-digit years
ddmmyyyy. See this issue to get a parser that works with 2-digit years, but please read everything to see how IE behaves with 2-digit years.Third, because of the content of the date column, you’ll need to set the sorter option in the header:
And lastly, there were two
textExtractionoptions in the demo. The second one, not the one you posted above, was overriding the function. The one you wrote works perfectly 🙂Here is a demo of the above mentioned changes.
Update: Here’s an updated demo using the following parser code: