Sorting Datetime removes all other functionality of datatable
Sorting Datetime removes all other functionality of datatable
HussainAbdulMajeed
Posts: 7Questions: 2Answers: 0
On trying to add the Ultimate date / time sorting plugin, I'm able to sort the date but all the other features of data table like sorting,search, pagination goes away.
I've done the following:
Added moment.js to my page
Added datetime-moment.js to my page.
$(document).ready(function () {
$.fn.dataTable.moment('D/M/YYYY h:mm:ss A');
$('#OnProcess').dataTable({
language: {
sZeroRecords: 'لا توجد سجلات مطابقة',
sEmptyTable: 'لا توجد البيانات',
search: "_INPUT_",
searchPlaceholder: "ابحث هنا...",
oPaginate: {
sNext: '',
sPrevious: '',
}
},
"aLengthMenu": [[10, 15, 20 - 1], [10, 15, 20, "All"]],
"iDisplayLength": 10,
"columnDefs": [{
"className": "dt-right", "targets": "_all",
}],
"columnDefs": [{
"targets": 2, //,"orderable": false
"render": $.fn.dataTable.render.ellipsis(25, true)
}]
});
})
What could be the problem?
This question has accepted answers - jump to:
This discussion has been closed.
Answers
That suggests a Javascript error is happening on the page. If you link to a test page showing the issue I can take a look. Otherwise, take a look in your browser's inspector.
Allan
After inspecting i'm getting this error
That error suggests that
$.fn.dataTable
isundefined
- which means that DataTables hasn't been loaded.Are you loading DataTables before the Moment plug-in for DataTables?
Allan
No the plugin is initialized before calling the Datatable.
<script src="~/assets/js/jquery-1.10.2.js" type="text/javascript"></script>
<script src="~/scripts/datatable/jquery.dataTables.min.js"></script>
<script src="~/scripts/datatable/moment.min.js"></script>
<script src="~/scripts/datatable/datetime-moment.js"></script>
The error goes away when i order the script in this manner, but the datetime sorting doesn't occur
Thanks a lot i got the error solved. It was in the order of the script plugin.