Datatable date sort not work.

Datatable date sort not work.

sanjayacloudsanjayacloud Posts: 1Questions: 1Answers: 0

Hi I have use datatable in my project. I want to sort my date column. Its not work. But other column sort work fine. here's my code.

$(document).ready(function () {
        $('#purchase-history').daterangepicker(null, function (start, end, label) {
            bringData( start.format('YYYY-MM-DD') , end.format('YYYY-MM-DD'));
        });
        bringData('{{date("Y/m/d" , strtotime("-1 months"))}}' , '{{date("Y/m/d")}}');
        function bringData(start, end) {
            $.ajax({
                url: base + '/admin/used-boxes-data',
                type: 'post',
                data: 'start='+start+'&end='+end,
                async: false,
                success: function (respond) {
                    if (respond.success) {
                        $('#content').html(respond.data);
                          $("#used").DataTable({
                                dom: "Blfrtip",
                                buttons: [
                                    {
                                        extend: "copy",
                                        className: "btn-sm"
                                    },
                                    {
                                        extend: "csv",
                                        className: "btn-sm"
                                    },
                                    {
                                        extend: "excel",
                                        className: "btn-sm"
                                    },
                                    {
                                        extend: "pdfHtml5",
                                        className: "btn-sm"
                                    },
                                    {
                                        extend: "print",
                                        className: "btn-sm"
                                    }
                                ],
                                responsive: true,
                              order: [[ 1, "desc" ]],
                              columnDefs : [{"targets":1, "type":"date-eu"}],
                            });

                    } else {

                    }
                },
                complete: function () {
                }
            });
        }
    });

Answers

This discussion has been closed.