:: Forum >> Version 2 >>

Sorting date column

Hi,

I have a grid with a column that contain dates.
When I try to sort the data according to this column it sort it is not sorted well.
How can I fix it?
I tried several solutions here (basiclly using setCellData and setCellText) but it didn't help much or I didn't use it correctly.

Thanks,
YaronP
YaronP
Tuesday, June 6, 2006
If you assign the cell content as text with setCellText() method - you should use date formatting object with the text format matching the actual content. The formatting object will provide textToValue() transformation (= correct sorting).

var myText = [
        [
1"May 1, 2006"],
        [
2"Jun 1, 2005"],
        [
3"Sep 1, 2004"]
    ]

    var 
date = new AW.Formats.Date;
    
date.setTextFormat("mmm d, yyyy");

    var 
obj = new AW.UI.Grid;
    
obj.setCellText(myText);
    
obj.setCellFormat(date1);

    
obj.setColumnCount(2);
    
obj.setRowCount(3);

    
document.write(obj);
 
There are also some examples in /examples/old/xml-dataset.htm, xml-array-of-records.htm, but those work in an opposite way (data->text, data->value).
Alex (ActiveWidgets)
Wednesday, June 7, 2006



This topic is archived.

Back to support forum

Forum search