How to sort date time columns
How to sort date time columns
I am trying to get sorting column in datetime by following below link but it is not working for me.
https://datatables.net/plug-ins/sorting/datetime-moment
Used below code
var ticketTable;
j$ = jQuery.noConflict();
j$.fn.dataTable.moment( 'HH:mm MMM D, YY' );
ticketTable = j$('[id$="ticketTable"]').DataTable({
columnDefs: [{ type: 'natural', targets: 0 }]//for natural sorting for column 1
});
Getting error below:
Uncaught TypeError: j$.fn.dataTable.moment is not a function
Answers
Did you include both JS files needed as described in the referenced blog post?
https://datatables.net/blog/2014-12-18
Kevin
Yes. I have included them both //cdnjs.cloudflare.com/ajax/libs/moment.js/2.8.4/moment.min.js
and //cdn.datatables.net/plug-ins/1.10.15/sorting/datetime-moment.js
I put your init code into an example that works (didn't load the natural plugin):
http://live.datatables.net/dowoyose/1/edit
Maybe there is a conflict or load order issue with your include files. Can you post a link showing the issue?
Kevin
Okay thanks I will check by removing some other plugin
Hi @kthorngren ,
Yes you are right, it is getting conflict from natural.js
What can be done to have both working together?