sorting by uk date and time regex not working

sorting by uk date and time regex not working

sleeslee Posts: 2Questions: 0Answers: 0
edited September 2013 in General
I am using Ronan Guilloux sorting code (although i removed the seconds) and i can set the columns using aoColumnDefs which works with the time as well but id like to not have to set the column so i have been trying to use the following:

[code]jQuery.fn.dataTableExt.aTypes.unshift(
function ( sData )
{
if (sData !== null && sData.match(/(0[1-9]|[12]\d|3[0-2])\/(0[1-9]|1[0-2])\/\d{4} (0[1-9]|1\d|2[0-3]):(0[1-9]|[1-5]\d)$/))
{
console.log('datetime-uk');
return 'datetime-uk';
}
return null;
}
);[/code]

But it is not working. the column has the format like this:

[code]14/09/2013 11:15[/code]

The regEx i have above seems to work in tools on the page and i can see that it does match it but then the datetime-uk methods are never called. if i set the aoColumnDefs it does call them and everything works can anyone help?

Replies

  • sleeslee Posts: 2Questions: 0Answers: 0
    After playing with it for some time i had to abandon the regEx and i simply added this to the set up:

    [code]
    aoColumnDefs: [{ "sType": "datetime-uk", "aTargets": [whichCol] }]
    [/code]

    I then set the whichCol var to either null or a column number if it was on the page that needed this UK sorting.
This discussion has been closed.