Order by data

Order by data

gerennegerenne Posts: 30Questions: 0Answers: 0
edited June 2012 in General
Hi all,

I have a problem with the order of column date in table:

oTable =$('#idTable').dataTable( {
"bFilter" : false,
"bRetrieve": true,
"bDestroy": true,
"fnDrawCallback":
function() {
clickRowHandler();
},
"aoColumnDefs": [
{"bVisible": false,
"aTargets": [ 9 ]
}],
"aaSorting": [ [7,'asc'] ]

} );

The column seven is a date column with the format "dd/mm/yy hh:mm:ss", and the table show this order:

2/06/12 0:00:00
24/05/12 0:00:00
25/05/12 0:00:00
26/05/12 0:00:00
27/06/12 0:00:00
31/05/12 0:00:00

Thanks in advance.

Replies

  • allanallan Posts: 63,501Questions: 1Answers: 10,471 Site admin
    I think you'll need to use a date sorting plug-in: http://datatables.net/plug-ins/sorting#date_eu

    Allan
  • gerennegerenne Posts: 30Questions: 0Answers: 0
    ok thanks Allan, now is working.

    But my problem now is other, I need load the table in a determinate page, and now I don't know the position of tr, because I don't know the order of table until the table is loaded.

    Ej:
    $('#table tbody tr').each( function(i) {

    var aData=$('td', this);
    var iIdRow=$(aData[1]).text();
    if (i%10==0){
    nMod=i;
    }

    if (iId==iIdRow){ //iId --> global value
    $('#table tbody tr:eq('+i+')').addClass('row_selected');
    nPageIni=nMod;
    }


    } );

    oTable =$('#table').dataTable( {
    "bFilter" : false,
    "bRetrieve": true,
    "bDestroy": true,
    "iDisplayStart": nPageIni, //the value is correct before to order table
    "fnDrawCallback":
    function() {
    clickRowHandler();
    },
    "aoColumnDefs": [
    {"bVisible": false,
    "aTargets": [ 9 ]
    }],
    "aaSorting": [ [9,'asc'], [7,'asc'],[4,'asc'] ],
    "aoColumns": [
    null,
    null,
    null,
    null,
    null,
    null,
    null,
    { "sType": "date-euro" },
    null,
    null]

    } );
  • allanallan Posts: 63,501Questions: 1Answers: 10,471 Site admin
    I don't quite understand why you want to change iDisplayStart at all, and what you are hoping to achieve by doing so I'm afraid.

    Having said that, this API plug-in might help: http://datatables.net/plug-ins/api#fnDisplayRow .

    Allan
  • gerennegerenne Posts: 30Questions: 0Answers: 0
    Hi Allan.

    I want to change iDisplayStart because when I obtained the number of page, the table isn't in the correct order, when table do the load and to order the table, the number of page that I was obtained isn't valid, because this number has been obtained before to order the table.

    Thanks in advance.
This discussion has been closed.