Categories | Question details Back To List | ||
Handling blank cells while sorting dates While sorting dates, if any of the cells is blank, then the sorting seems to go haywire. That is, only the values before the blank get sorted, leaving out the ones, after the blank. For example, suppose I'm loading the following data: // -- grid data -- <row id="a"> <cell>Model 1</cell> <cell>100</cell> <cell>08/22/2007 00:00:00</cell> </row> <row id="b"> <cell>Model 2</cell> <cell>50</cell> <cell>08/22/1997 00:00:00</cell> </row> <row id="c"> <cell>MOdel 3</cell> <cell>70</cell> <cell></cell> </row> <row id="d"> <cell>MOdel 4</cell> <cell>700</cell> <cell>08/21/2007 00:00:00</cell> </row> // -- grid data end -- In the HTML, I've set the sorting as: // other initializations ... ... // sorting type mygrid.setColSorting("str,int,date"); ...so that the last column gets sorted as a date. Once I click on the date header for sorting, the first three (date) values get consolidated, leaving the last date row as the last one. This row always remains as the last one, regardless of any subsequent clicks for sorting. Could anyone please advise on this? Answer posted on Aug 25, 2008 01:47 The empty date treated as "very old date" ( technically it converted to the 01/01/1900 ) and sorted accordingly ( first record in asc order, last record in desc order ) If such behavior is not expected one, you can always assign custom sorting function to column in question. http://dhtmlx.com/docs/products/dhtmlxGrid/doc/articles/Sorting_in_grid.html#grid_art_sort |