Sort by custom date format

Hi,



I have a problem to implement sorting by custom date in treegrid header. I found an algorithm, with that it should be realized. So it is a custom sort. My question is, how it could be implemented (look at ? in the sample). To date there are errors.



sample:























var mygrid;

function doInitGrid() {



mygrid = new dhtmlXGridObject(‘gridbox’);



mygrid.imgURL = “imgs/”;



mygrid.setHeader("Number, ,Text,date, ");

mygrid.setInitWidths("150,30,,70,20");

mygrid.setColAlign(“left,left,left,right,left”);

mygrid.setColTypes(“tree,img,ro,ro?,ro”);

mygrid.setColSorting(“str,na,na,???,na”);

mygrid.enableTreeCellEdit(false);



mygrid.init();

mygrid.kidsXmlFile=“dbtoxmlkids.xml”;

mygrid.loadXML(“dbtoxml.xml”);

}

function date_custom=function(a,b,order){ //date format dd.mm.yy

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);

}



Thanks and best regards

mygrid.setColTypes(“tree,img,ro,ro,ro”);
mygrid.setColSorting(“str,na,na,date_custom,na”);

Beware that custom sorting works only in pro version of grid.


Yes, Pro version of grid is in use. Where is the custom function to be implemented? It always shows the error: Missing ( before function parameter.



 







function doInitGrid(){



}



function date_custom=function(a,b,order){



}









a) try to change
function date_custom=function(a,b,order){
as
function date_custom(a,b,order){

b) the function must be defined on moment of setColSorting call

If necessary we can provide a working sample ( please contact us at support@dhtmlx.com for such example )