Date formats converter class. Parses the date strings and handles transformations from one date format to another, typically from 'transport' (datasource) formats, like ISO8601 or RFC822, to the display formats, for example 'mmm-dd-yyyy' or similar.
To configure the object specify the format of the date strings in the datasource with the setDataFormat() method and set the output text format with setTextFormat() method.
To activate the date conversion and enable correct date sorting assign the configured date object to the grid column with setCellFormat() call.
var obj = new AW.Formats.Date;
clone | Creates an object clone. |
comparator | Returns comparator function. |
dataToText | Transforms the external data to the readable text. |
dataToValue | Transforms the external data to the native value type. |
init | Initializes the object. |
setDataFormat | Sets the formatting pattern for the external data. |
setDataTimezone | Sets the timezone for the external data. |
setErrorText | Sets the error text. |
setErrorValue | Sets the error value. |
setTextFormat | Sets the formatting pattern for the text. |
setTextTimezone | Sets the timezone for the text. |
setTimeout | Calls the function after the specified delay. |
textToData | Transforms the text to the external data format. |
textToValue | Transforms the text to the native value type. |
toString | Converts object to string. |
valueToData | Transforms the value to the external data format. |
valueToText | Transforms the value to the readable text. |
// datasource with dates in iso8601 format
var myData = [
["Grid 1.0", "2004-05-18T00:00:00+01:00"],
["ActiveWidgets 2.0", "2006-02-08T00:00:00+01:00"]
];
// date converter
var date = new AW.Formats.Date;
date.setDataFormat("ISO8601");
date.setTextFormat("mmm-dd-yyyy");
// grid control
var obj = new AW.UI.Grid;
obj.setCellData(myData);
obj.setCellFormat(date, 1) // dates in the second column
obj.setColumnCount(2);
obj.setRowCount(2);
document.write(obj);
setDataFormat, setTextFormat, setCellFormat methods