Sorting Datetime removes all other functionality of datatable

Sorting Datetime removes all other functionality of datatable

HussainAbdulMajeedHussainAbdulMajeed Posts: 7Questions: 2Answers: 0
edited May 2018 in Free community support

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:

Answers

  • allanallan Posts: 63,455Questions: 1Answers: 10,465 Site admin
    Answer ✓

    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

  • HussainAbdulMajeedHussainAbdulMajeed Posts: 7Questions: 2Answers: 0

    After inspecting i'm getting this error

  • allanallan Posts: 63,455Questions: 1Answers: 10,465 Site admin
    Answer ✓

    That error suggests that $.fn.dataTable is undefined - which means that DataTables hasn't been loaded.

    Are you loading DataTables before the Moment plug-in for DataTables?

    Allan

  • HussainAbdulMajeedHussainAbdulMajeed Posts: 7Questions: 2Answers: 0

    No the plugin is initialized before calling the Datatable.

  • HussainAbdulMajeedHussainAbdulMajeed Posts: 7Questions: 2Answers: 0

    <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

  • HussainAbdulMajeedHussainAbdulMajeed Posts: 7Questions: 2Answers: 0

    Thanks a lot i got the error solved. It was in the order of the script plugin.

This discussion has been closed.