fix sorting on accounts page
This commit is contained in:
parent
860f6ab356
commit
f5369c05ac
@ -90,20 +90,27 @@
|
|||||||
<script src="https://cdn.datatables.net/responsive/2.2.9/js/dataTables.responsive.min.js"></script>
|
<script src="https://cdn.datatables.net/responsive/2.2.9/js/dataTables.responsive.min.js"></script>
|
||||||
<script>
|
<script>
|
||||||
$(document).ready(function() {
|
$(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('/');
|
const parts = data.split('/');
|
||||||
|
// 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 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({
|
$('#accountsTable').DataTable({
|
||||||
"searching": true,
|
"searching": true,
|
||||||
"ordering": true,
|
"ordering": true,
|
||||||
"responsive": true,
|
"responsive": true,
|
||||||
"columnDefs": [
|
"columnDefs": [
|
||||||
{ "type": "date-eu", "targets": 4 }
|
{ "type": "date-eu", "targets": 4 } // Use custom date-eu type for the date column
|
||||||
]
|
]
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user