Categories | Question details Back To List | ||
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: <link rel="stylesheet" type="text/css" href="codebase/gridstyles.css"> <script type="text/javascript" src="codebase/dhtmlxcommon.js"></script> <script type="text/javascript" src="codebase/dhtmlxgrid.js"></script> <script type="text/javascript" src="codebase/dhtmlxgridcell.js"></script> <script type="text/javascript" src="codebase/dhtmlxtreegrid.js"></script> 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 Answer posted by Stanislav (support) on Oct 23, 2009 05:12 mygrid.setColTypes("tree,img,ro,ro,ro"); mygrid.setColSorting("str,na,na,date_custom,na"); Answer posted by Stanislav (support) on Oct 23, 2009 05:12 Beware that custom sorting works only in pro version of grid. Answer posted by Janet K. on Oct 23, 2009 23:12 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.
<script> function doInitGrid(){ } function date_custom=function(a,b,order){ } <script> <body>... Answer posted by Stanislav (support) on Oct 26, 2009 03:54 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 ) |