ソースを参照

fix sorting on accounts page

Karl Hudgell 4 週間 前
コミット
f5369c05ac
1 ファイル変更11 行追加4 行削除
  1. 11 4
      templates/user_accounts.html

+ 11 - 4
templates/user_accounts.html

@@ -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>