After fiddling with my table layout I give up, I am looking for up to date and elegant way to sort this table layout with such numbers.
I tried this popular solution.
jQuery.extend( jQuery.fn.dataTableExt.oSort, {
"formatted_numbers-pre": function ( a ) {
a = (a===" ") ? 0 : a.replace( /[^\d\-\.]/g, "" );
return parseFloat( a );
},
"formatted_numbers-asc": function ( a, b ) {
return a - b;
},
"formatted_numbers-desc": function ( a, b ) {
return b - a;
}
});
jQuery(document).ready(function() {
jQuery('#mieszkaniaList').DataTable({
responsive: true,
"columnDefs": [
{ "type": "formatted_numbers", "targets": '_all'},
],
"language": {
"decimal": ",",
"thousands": " ",
"lengthMenu": "Pokaż _MENU_ mieszkań na stronę",
"zeroRecords": "Niestety dla tego zakresu nie znaleźliśmy pasujących mieszkań ...",
"info": "Strona _PAGE_ z _PAGES_",
"infoEmpty": "Niestety brak mieszkań...",
"processing": "Przygotowujemy mieszkania...",
"search": "Szukaj",
"paginate": {
"first": "Pierwsza",
"last": "Ostatnia",
"next": "Następna",
"previous": "Poprzednia"
},
"infoFiltered": "(z _MAX_ mieszkań)"
}
});
});
| Nr | Area | level | nr2 | Price | Price per m2 |
|---|---|---|---|---|---|
| 01A | 10 m2 | 1 | 1 | 502 200 PLN | 7 200 PLN za m2 |
| 02A | 20 m2 | 2 | 2 | 1 502 200 PLN | 10 200 PLN za m2 |
| 03A | 90 m2 | 3 | 3 | 2 502 200 PLN | 15 200 PLN za m2 |
| 04A | 120 m2 | 4 | 4 | 202 200 PLN | 5 200 PLN za m2 |