sorting problems with "Ultimate date plugin"
sorting problems with "Ultimate date plugin"
mbcl88
Posts: 13Questions: 5Answers: 0
Hey,
like i sad i have problem with sorting my dates, i have dates like 01.12.2018, 11.12.2018, 12.11.2018, etc
so i tried with that plugin but cant figure out how to implement ($.fn.dataTable.moment( 'd.m.Y' );) this in my js code, my code looks like below, where i made mistake?
<script>
$(document).ready(function() {
$.fn.dataTable.moment( 'd.m.Y' );
$('#test').DataTable( {
responsive: true,
"info": false,
"paging": false,
"columnDefs": [ {
"targets": 4,
"orderable": false
} ],
columnDefs: [
{ type: 'any-number', targets: 0 }
],
"language": {
"url": "//cdn.datatables.net/plug-ins/1.10.19/i18n/Slovenian.json"
},
"order": [[ 0, "desc" ]],
} );
} );
</script>
This discussion has been closed.
Answers
ups
It looks like you may have the wrong format of
'd.m.Y'
. Here is the moment.js format docs:https://momentjs.com/docs/#/parsing/string-format/
I think you will want this format:
DD.MM.YYYY
If this doesn't work then please provide a test case so we can help debug:
https://datatables.net/manual/tech-notes/10#How-to-provide-a-test-case
Kevin
so syntax of code which i pasted is okay? i just need to change 'd.m.Y' to 'DD.MM.YYY' ?
Sounds like it! Here is more on international sorting / ordering:
https://stackoverflow.com/questions/53238318/html5-javascript-datatables-order-sort-of-columns/53238593#53238593
I recommend you use the moment. js locale files instead of hard coding "DD.MM.YYYY"