3.2.0

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
June 6,
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(date, 1);

    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)
June 7,

This topic is archived.

See also:


Back to support forum