Hi there,
I'm using a custom sorting in order to order a datetime field in the grid, but there's no reaction from the grid when I click on the title. Here's what I have so far:
function dateTimeCustom(a,b,order)
{
var date1 = a.split(" ")[0].split("-");
var date2 = b.split(" ")[0].split("-");
var time1 = a.split(" ")[1].split(":");
var time2 = b.split(" ")[1].split(":");
if(date1[0] == date2[0])
{
if(date1[1] == date2[1])
{
if (date1[2] == date2[2])
{
if (time1[0] == time2[0])
{
if (time1[1] == time2[1])
{
return (time1[2] > time2[2] ? 1 : -1) * (order=="asc" ? 1 : -1);
}
else
{
return (time1[1] > time2[1] ? 1 : -1) * (order=="asc" ? 1 : -1);
}
}
else
{
return (time1[0] > time2[0] ? 1 : -1) * (order=="asc" ? 1 : -1);
}
}
else
{
return (date1[2] > date2[2] ? 1 : -1) * (order=="asc" ? 1 : -1);
}
}
else
{
return (date1[1] > date2[1] ? 1 : -1) * (order=="asc" ? 1 : -1);
}
}
else
{
return (date1[0] > date2[0] ? 1 : -1) * (order=="asc" ? 1 : -1);
}
}
function initGrid()
{
mygrid = new dhtmlXGridObject('gridbox');
mygrid.setImagePath("js/dhtmlxGrid/codebase/imgs/");
mygrid.setHeader("Client, Division, Titre, Description, Date début, Date fin, Priorité, Destinataire, Statut, PrcComplete");
mygrid.setInitWidths("*,*,*,*,*,*,*,*,*,*");
//mygrid.setInitWidths("50, 50, 100, 130, 100, 130, 130, 50, 50, 50, 50");
mygrid.setColAlign("left,left,left,left,left,left,left,left,left,left");
mygrid.setColTypes("ro,ro,ro,ro,ro,ro,ro,ro,ro,ro");
//mygrid.setColTypes("dyn,ed,txt,price,ch,coro,ch,ro");
mygrid.setSkin("dhx_skyblue");
mygrid.setColSorting("str,str,str,str,dateTimeCustom,dateTimeCustom,int,str,str,int");
//mygrid.setCustomSorting(dateTimeCustom, 4);
//mygrid.setDateFormat("yyyy-mm-dd HH:MM:ss");
//mygrid.setColSorting("int,str,str,int,str,str,str,date");
//alert(dateTimeCustom("2010-11-01 08:12:45", "2010-11-01 08:13:45", "asc"));
//alert(dateTimeCustom("2010-11-01 08:13:45", "2010-11-01 08:12:45", "asc"));
mygrid.init();
mygrid.loadXML("getListe.php");
mygrid.attachHeader("#select_filter,#rspan,#rspan,#rspan,#rspan,#rspan,#rspan,#rspan,#select_filter,#rspan");
//mygrid.makeFilter("statut",9);
//mygrid.groupBy(8);
}
Anyway, any help would be greatly appreciated. Thanks in advance.
Osu