Start Building Professional
Web Apps Today


 
Categories Question details Back To List
Question  posted by Vanessa Turney on Jun 23, 2008 05:42
open dhtmlx forum
Sorting by Date

Hi, we are using the pro version of dhtmlXGrid, and trying to sort by date (in the format dd/mm/yyyy) using the following taken from your documentation:

TagGridBox.setColTypes("ro,ro,ro,img,ro,ro,ro");
function date_custom(a,b,order)
{
a=a.split("/")
b=a.split("/")
if (a[2]==b[2])
{
if (a[1]==b[1])
     return (a[0]>b[0]?1:-1)*(order=="asc"?1:-1);
 else
     return (a[1]>b[1]?1:-1)*(order=="asc"?1:-1);
 }
 else
    return (a[2]>b[2]?1:-1)*(order=="asc"?1:-1);
}
TagGridBox.setColSorting("str,str,str,str,date,date_custom,date");

However when trying to sort the column by clicking on the header we get a javascript error - 'object does not support this property or method ', I've clearly missed something if someone could point me in the right direction.

When using the SetCustomSorting method on column 5 it runs fine but only sorts the date by the first two digits regardless of the month,

Kind Regards,

Vanessa Turney

Answer posted on Jun 23, 2008 08:36
There is type in code snippet, sorry for inconvenience.
The correct code will be

function date_custom(a,b,order)
{
a=a.split("/")
b=b.split("/")