Sorting on date including time portion but displaying just date portion?

Sorting on date including time portion but displaying just date portion?

motguptamotgupta Posts: 19Questions: 5Answers: 0
edited December 2012 in DataTables 1.9
i am sending the date as string from server as explained below which has both date and time part like 2010-12-07 17:35:04.127.
what i want is just display the date not the time part in data table column i.e 2010-12-07. But also i want the sorting happens
on complete date including the time part. So customer created at 2010-12-07 18:35:04.12 should be displayed above
2010-12-07 17:35:04.12 in dataTable column

[code]
"aoColumns": [ { "mDataProp": "customerCreated","bSearchable": false,
"fnRender": function ( o, val )
{
var javascriptDate = new Date(o.aData["customerCreated"]);
javascriptDate = javascriptDate.getFullYear()+"/"+javascriptDate.getMonth()+"/"+javascriptDate.getDate();
return ""+javascriptDate+"";
}

} ]

[/code]


But sorting does not happen correctly. I mean customer created at 2010-12-07 17:35:04.12 displayed in datatable above of customer
created afterwards i.e at 2010-12-07 18:20:02.16. i mean sorting does not work for the customer created on same date.Looks like it is
happening becoz we removed the timepart from date. Is there a solution where i can just display the date excluding time part but
sorting happens based on date and time?

Replies

  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin
    Sounds like you might want this: http://datatables.net/blog/Orthogonal_data .

    Allan
This discussion has been closed.