date column order in google chrome

date column order in google chrome

thlehthleh Posts: 1Questions: 0Answers: 0
edited February 2011 in General
Hey,

i have problems to sort a date column correctly. Is i run the following code in IE and firefox it works fine, but in google chrome (version 9.0.597.98) it's not sorted correctly.

[code]
oTable = $('#example').dataTable( {
"bPaginate": false,
"bLengthChange": false,
"bFilter": false,
"bSort": true,
"bInfo": false,
"bAutoWidth": false,
"aoColumns": [
{ "sType": "date" },
{ "sType": "numeric" },
{ "sType": "numeric" },
{ "sType": "numeric" },
{ "sType": "numeric" },
{ "sType": "numeric" },
{ "sType": "numeric" },
{ "sType": "numeric" },
{ "sType": "numeric" },
{ "sType": "numeric" },
{ "bSortable": false },
{ "bVisible": false,
"bSearchable": false }
]
});
[/code]

I use the german date format for the date column - e.g. 27.11.2010 28.12.2010 19.01.2011 09.02.2011 aso.

I'm running jQuery 1.5 and datatables 1.7.5.
Any idea whats wrong ?

Thanks in advance
Thomas

Replies

  • ultrageoffultrageoff Posts: 3Questions: 0Answers: 0
    Hi Thomas. I'm in the UK, apologies for all references to 'UK' in this answer; the plugin you need should also work for German people! I have just put a test site together with a UK/German date formatted column on all tables. There are plugin scripts for 'detection' of UK format dates, but I have a problem believing that any script can know that 11/12/2011 and 12/11/2011 are UK/German rather than US. So I think you need the sorting plugin and to declare that the sType of your first column is "uk_date". You'll need the Date(dd/mm/yy) plugin from http://datatables.net/plug-ins/sorting and to give the script a file name such as the "ukdatesort.js" that I used. Those little icons help with copying the code into Notepad (or whatever text editor you use to make your own script file), btw. My own code, with the fifth column having the date, is:
    [code]




    $(document).ready(function(){
    $('.dataTable').dataTable( {
    "bPaginate": false,
    "bLengthChange": false,
    "bAutoWidth": false,
    "bFilter": false,
    "bSort": true,
    "bInfo": false,
    "aoColumns": [
    null,
    null,
    null,
    null,
    {"sType": "uk_date"},
    null
    ]

    } );


    });


    [/code]

    Hope something equivalent to that works for you.
This discussion has been closed.