Sort With Moment

Sort With Moment

eyal_hbeyal_hb Posts: 98Questions: 31Answers: 0

i try to sort date with moment in datatable, but its seem that the order function order not by the value

here my code:

 "columns": [
            { "data": "OrderId", "name": "OrderId" },
            { "data": "CustomerId", "name": "CustomerId", "orderable": false },
            { "data": "RefundType", "name": "RefundType", "autoWidth": true },
            { "data": "RefundReason", "name": "RefundReason", "autoWidth": true },
            { "data": "PaymentType", "name": "PaymentType", "autoWidth": true },
            {
                "data": "RefundDate", "name": "RefundDate", "autoWidth": true,
                 render: function (data, type, row) {
                     return type == 'display' ? moment(data, "MMM DD YYYY HH: ssa").format('DD/MM/YYYY') : data
                }
            },
            { "data": "RefundValue", "name": "RefundValue", "autoWidth": true },



        ],
        "order": [[5, "desc"]],

    });

HERE MY RESULT:

how can i fix it?

the format i get form server is:

Answers

  • kthorngrenkthorngren Posts: 21,166Questions: 26Answers: 4,921

    The recommended solution for datetime sorting is discussed in this blog.

    Kevin

This discussion has been closed.