fix sorting on accounts page

This commit is contained in:
Karl Hudgell 2024-11-05 14:34:53 +00:00
parent 860f6ab356
commit f5369c05ac

View File

@ -90,20 +90,27 @@
<script src="https://cdn.datatables.net/responsive/2.2.9/js/dataTables.responsive.min.js"></script>
<script>
$(document).ready(function() {
$.fn.dataTable.ext.type.order['date-eu'] = function(data) {
// Extend DataTables date sorting for DD/MM/YYYY format
$.fn.dataTable.ext.type.order['date-eu-pre'] = function(data) {
const parts = data.split('/');
return new Date(parts[2], parts[1] - 1, parts[0]).getTime();
// Check if the data is in the correct format before processing
if (parts.length === 3) {
return new Date(parts[2], parts[1] - 1, parts[0]).getTime();
}
return data; // return as is if the format is unexpected
};
// Initialize DataTable with custom sorting
$('#accountsTable').DataTable({
"searching": true,
"ordering": true,
"responsive": true,
"columnDefs": [
{ "type": "date-eu", "targets": 4 }
{ "type": "date-eu", "targets": 4 } // Use custom date-eu type for the date column
]
});
});
</script>
</body>
</html>