DataTable
HTML
<link rel="stylesheet" href="https://cdn.datatables.net/1.10.13/css/jquery.dataTables.min.css">
<script src="https://cdn.datatables.net/1.10.13/js/jquery.dataTables.min.js"></script>
<table class="table table-striped table-bordered dataTable dt-tarif">
<thead>
<tr>
<th class="no-sort center-th">A</th>
<th>Versicherer</th>
<th>Tarif</th>
<th>Rating</th>
<th>Price</th>
</tr>
</thead>
<tfoot>
<tr>
<th class="center-th">A</th>
<th>Versicherer</th>
<th>Tarif</th>
<th>Rating</th>
<th>Price</th>
</tr>
</tfoot>
<tbody>
<tr>
<td><input type="checkbox"></td>
<td>Condor Privatschutz</td>
<td>A-Tarif</td>
<td>2</td>
<td>11,56€</td>
</tr>
<tr>
<td><input type="checkbox"></td>
<td>Europa Versicherung AG</td>
<td>B-Tarif</td>
<td>4</td>
<td>269,75€</td>
</tr>
<tr>
<td><input type="checkbox"></td>
<td>DEVK Deutschland</td>
<td>C-Tarif</td>
<td>6</td>
<td>505,25€</td>
</tr>
<tr>
<td><input type="checkbox"></td>
<td>Feuersozität</td>
<td>D-Tarif</td>
<td>1</td>
<td>100,45€</td>
</tr>
<tr>
<td><input type="checkbox"></td>
<td>Europa Versicherung AG</td>
<td>B-Tarif</td>
<td>4</td>
<td>269,75€</td>
</tr>
<tr>
<td><input type="checkbox"></td>
<td>Europa Versicherung AG</td>
<td>B-Tarif</td>
<td>4</td>
<td>99,99€</td>
</tr>
<tr>
<td><input type="checkbox"></td>
<td>Europa Versicherung AG</td>
<td>B-Tarif</td>
<td>4</td>
<td>999,99€</td>
</tr>
<tr>
<td><input...
JavaScript
/**
* This plug-in will provide numeric sorting for currency columns (either
* detected automatically with the currency type detection plug-in or set
* manually) while taking account of the currency symbol ($ or £ by default).
*
* DataTables 1.10+ has currency sorting abilities built-in and will be
* automatically detected. As such this plug-in is marked as deprecated, but
* might be useful when working with old versions of DataTables.
*
* @name Currency
* @summary Sort data numerically when it has a leading currency symbol.
* @deprecated
* @author [Allan Jardine](http://sprymedia.co.uk)
*
* @example
* $('#example').dataTable( {
* columnDefs: [
* { type: 'currency', targets: 0 }
* ]
* } );
*/
jQuery.extend( jQuery.fn.dataTableExt.oSort, {
"currency-pre": function ( a ) {
a = (a==="-") ? 0 : a.replace( /[^\d\-\.]/g, "" );
return parseFloat( a );
},
"currency-asc": function ( a, b ) {
return a - b;
},
"currency-desc": function ( a, b ) {
return b - a;
}
} );
jQuery.extend( jQuery.fn.dataTableExt.oSort, {
"currency": function ( a ) {
var x = a.replace(",", ".").replace("€", "");
return parseFloat( x );
}});
var mytable = $('table.dt-tarif').dataTable({
"paging": false,
"info": false,
"searching": false,
// add second sorting
"order": [[3, "desc"], [4, "asc"]],
"aoColumnDefs": [
{
"bSortable": false,
"aTargets": [0]
},
// change type name to match above
{
"type": "currency", targets: 4
}
],
"language": {
"lengthMenu": "Zeige _MENU_",
"zeroRecords": "Keine Entwürfe vorhanden!",
"info": "Seite _PAGE_ von _PAGES_",
"infoEmpty": "Es konnte kein Entwurf gefunden werden.",
...