Table Sorter
Utilizando o plugin "Table Sorter" com ordenação de data e moeda brasileiro!
by gsguma
HTML
<script src="http://tablesorter.com/__jquery.tablesorter.min.js"></script>
<link rel="stylesheet" href="http://getbootstrap.com/2.3.2/assets/css/bootstrap.css">
<table cellspacing="1" class="tablesorter table table-striped" id="tablesorter">
<thead>
<tr>
<th>Status</th>
<th>Description</th>
<th>Version</th>
<th>Environment</th>
<th>URL</th>
</tr>
</thead>
<tbody>
<tr>
<td><i class="icon icon-ok"></i>
</td>
<td>ePrint Enterprise</td>
<td>3.2</td>
<td>Development</td>
<td>https://epe-dev-32.test.lan</td>
</tr>
<tr>
<td><i class="icon icon-time"></i>
</td>
<td>ePrint Enterprise</td>
<td>3.2</td>
<td>Development</td>
<td>https://epe-dev-32.test.lan</td>
</tr>
<tr>
<td><i class="icon icon-remove"></i>
</td>
<td>HPAC</td>
<td>14</td>
<td>Development</td>
<td>https://epe-dev-32.test.lan</td>
</tr>
<tr>
<td><i class="icon icon-time"></i>
</td>
<td>ePrint Enterprise</td>
<td>2.2</td>
<td>Development</td>
<td>https://epe-dev-32.test.lan</td>
</tr>
<tr>
<td><i class="icon icon-time"></i>
</td>
<td>ePrint Enterprise</td>
<td>3.075205</td>
<td>Development</td>
<td>https://epe-dev-32.test.lan</td>
</tr>
<tr>
<td><i class="icon icon-time"></i>
</td>
<td>ePrint Enterprise</td>
<td>3.2</td>
<td>Development</td>
<td>https://epe-dev-32.test.lan</td>
</tr>
</tbody>
</table>
JavaScript
// Plugin
$.tablesorter.addParser({
id: 'number',
is: function (s) {
return false;
},
format: function (s) {
s = '' + s;
s = s.replace(new RegExp(/\D/g), '');
s = $.tablesorter.formatInt(s);
return s;
},
type: 'numeric'
});
// Zebra
$.tablesorter.defaults.widgets = ['zebra'];
// Add plugin
$("#tablesorter").tablesorter({
headers: {
2: {
sorter: 'number'
}
}
});