datetime-moment ordering not working
datetime-moment ordering not working
simsek97
Posts: 7Questions: 3Answers: 0
Hi everbody
i am trying to order date type column by using datetime-moment plugin. My workout is as below. (I ignored unnecessary parts)
<table id="myTable">
<thead>
<tr>
<th>Name</th>
<th class="sort-date">Birth Date</th>
</tr>
</thead>
</table>
<script type="text/javascript">
$(function(){
$.fn.dataTable.moment('MM.DD.YYYY');
$('#myTable').dataTable({
ajax: {
type: "POST",
url: "myUrl",
},
columns: [
{ data: "name", class: "text-center" },
{ data: "birthDate", class: "text-center" }
],
columnDefs: [
{ type: "datetime-moment", targets: "sort-date" }
]
});
});
</script>
But it does not work. Is there anything wrong?
I know the rules but sorry for that I can not give a test link since I am using it in a password protected area.
Thanks in advance.
This question has an accepted answers - jump to answer
This discussion has been closed.
Answers
Hi,
Maybe you'll find more information in the following 2 posts. They explain a lot on how to use moment.
https://datatables.net/forums/discussion/33852/datetime-moment-js-with-sharepoint-date-data
and
https://datatables.net/forums/discussion/35074/invalid-date-with-datetime-moment-js
To add to that:
Remove that. The plug-in will add automatic type detection - don't specify the type yourself.
It is isn't working it suggests that the data in the table is not in the format given to Moment. We'd need an example of the data you are working with.
Allan