How to use the plugin date-uk to sort dates in the format dd-mm-yyyy

How to use the plugin date-uk to sort dates in the format dd-mm-yyyy

dmyandmyan Posts: 1Questions: 1Answers: 0

I facced some problems when using the date-uk plugin and I found same question
here but it was not responded.

How do I use the plugin-uk date to sort the column of dates in dd-mm-yyyy format .. ?? thank you..

(Como faço para usar o plugin date-uk para ordenar a coluna de datas no formato dd-mm-yyyy..?? obrigado)

Being my table with 10 columns, the column is the date the eighth. I would have to specify the type of each of them in "columnDefs" ??

( Sendo minha tabela com 10 colunas, a coluna da data é a oitava. eu teria que especificar o tipo de cada uma delas em "columnDefs" ??)

Javascript Code:

script type="text/javascript"> $(function(){ $('#table-producao').dataTable({ "bJQueryUI": true, "language": { "url": >"../media/language/dataTables.ptbr.txt" }, "sPaginationType":"full_numbers",

Plain text
       "columnDefs": [               
           { "type": 'date-uk', "targets": 0 }       
           ]              
   });
})

Sorry for errors in english.. :D

Thanks!

I found a solution and I created this question since that I was not able to comment there.

Solution:

$(document).ready(function() {
    $.extend( jQuery.fn.dataTableExt.oSort, {
        "date-uk-pre": function (a){
            return parseInt(moment(a, "DD/MM/YYYY").format("X"), 10);
        },
        "date-uk-asc": function (a, b) {
            return a - b;
        },
        "date-uk-desc": function (a, b) {
            return b - a;
        }
    });

    var edit_date_col_num = $('th:contains("Edit Date")').index();
    var entry_date_col_num = $('th:contains("Entry Date")').index();

    var table = $('.mainTable').DataTable( {
        columnDefs: [
            { "type": "date-uk", targets: [ edit_date_col_num, entry_date_col_num ] }
        ]
    });
});

Thanks!

This discussion has been closed.