dataTable, Order By date Help plis!

dataTable, Order By date Help plis!

paulohenrique222paulohenrique222 Posts: 5Questions: 0Answers: 0
edited April 2013 in DataTables 1.9
Good Day for all,
(developing a system based on PHP and ZendFramework)

I'm here to ask for help the you, I have a "problem" in my dataTable, which is the following, I need listing by date one column, ie;

01/02/2013,

02/02/2013,

03/02/2013

Unfortunately, my dataTable is listing per day practically, it lists all the first day, then all two days, after all 3 days and so forth, example;


01/02/2013,

01/03/2013,

01/04/2013,

01/05/2013,

02/02/2013,

02/03/2013,

02/04/2013,

02/05/2013

Even when you can not see a solution.
I'm need help in question,
plis if someone have knowing, post for me plis.

Can anyone explain to me why she is doing the search this way?
or has a solution in mind that can help me.

Sorry, inglish not fluent language.
Thank you in the attention you got to look at this post.

Replies

  • paulohenrique222paulohenrique222 Posts: 5Questions: 0Answers: 0
    [code]
    jQuery.fn.dataTableExt.aTypes.push(
    function ( sData )
    {
    if (sData.match(/^(0[1-9]|[12][0-9]|3[01])\-(0[1-9]|1[012])\-(19|20|21)\d\d$/))
    {
    return 'uk_date';
    }
    return null;
    }
    );
    jQuery.fn.dataTableExt.oSort['uk_date-asc'] = function(a,b) {

    var ukDatea = a.split('/');
    var ukDateb = b.split('/');

    //Treat blank/non date formats as highest sort
    if (isNaN(parseInt(ukDatea[0]))) {
    return 1;
    }

    if (isNaN(parseInt(ukDateb[0]))) {
    return -1;
    }

    var x = (ukDatea[2] + ukDatea[1] + ukDatea[0]) * 1;
    var y = (ukDateb[2] + ukDateb[1] + ukDateb[0]) * 1;

    return ((x < y) ? -1 : ((x > y) ? 1 : 0));
    };

    jQuery.fn.dataTableExt.oSort['uk_date-desc'] = function(a,b) {
    var ukDatea = a.split('/');
    var ukDateb = b.split('/');

    //Treat blank/non date formats as highest sort
    if (isNaN(parseInt(ukDatea[0]))) {
    return -1;
    }

    if (isNaN(parseInt(ukDateb[0]))) {
    return 1;
    }

    var x = (ukDatea[2] + ukDatea[1] + ukDatea[0]) * 1;
    var y = (ukDateb[2] + ukDateb[1] + ukDateb[0]) * 1;

    return ((x < y) ? 1 : ((x > y) ? -1 : 0));
    };


    function aplicarDataTable(){
    $('#lista_metas_ativas').dataTable({
    "sPaginationType": "full_numbers",
    "oLanguage": {
    "sLengthMenu": "Mostrar _MENU_ metas por página",
    "sZeroRecords": "Nenhuma meta encontrada",
    "sInfo": "Mostrando de _START_ a _END_ de _TOTAL_ metas",
    "sInfoEmpty": "Mostrando de 0 a 0 de 0 metas",
    "sInfoFiltered": "(Filtrados de _MAX_ metas)",
    "sSearch": "Pesquisar:",
    "oPaginate": {
    "sFirst": "Primeira",
    "sLast": "Última",
    "sNext": "Próxima",
    "sPrevious": "Anterior",
    "aoColumns": [
    null,
    { "sType": "uk_date" },
    { "sType": "uk_date" },
    null,
    null
    ]
    }
    }
    });

    $("#lista_metas_inativas").dataTable({
    "sPaginationType": "full_numbers",
    "oLanguage": {
    "sLengthMenu": "Mostrar _MENU_ metas por página",
    "sZeroRecords": "Nenhuma meta encontrado",
    "sInfo": "Mostrando de _START_ a _END_ de _TOTAL_ metas",
    "sInfoEmpty": "Mostrando de 0 a 0 de 0 metas",
    "sInfoFiltered": "(Filtrados de _MAX_ metas)",
    "sSearch": "Pesquisar:",
    "oPaginate": {
    "sFirst": "Primeira",
    "sLast": "Última",
    "sNext": "Próxima",
    "sPrevious": "Anterior",
    "aoColumns": [
    null,
    { "sType": "uk_date" },
    { "sType": "uk_date" },
    null,
    null
    ]
    }
    }
    });

    $('#lista_metas_ativas_length select').chosen();
    $('#lista_metas_inativas_length select').chosen();
    }
    [/code]
  • allanallan Posts: 63,389Questions: 1Answers: 10,449 Site admin
    Are you saying that it works with the code from your second post, or not? If not, please link to a test case.

    Allan
  • paulohenrique222paulohenrique222 Posts: 5Questions: 0Answers: 0
    Thanks, i found a solution.
This discussion has been closed.