SMART datagrid v.1 > Examples

Back  Forward

Datetime Value  Example

1. Save Date Time Value in the data set

DataSet saves the field values which dataType is DATETIME as Date object of JavaScript. undefined, null or an empty string are saved as undefined. When transfer the values of DATETIME field through GridDataSet.setValue, you can transfer except Date object, undefined, null, ''. However, if the value cannot be directly recognized by JavaScript Date object, you should appropriately convert the format. 

DataSet converts the value according to the conversion format set in DataField.datetimeFormat or DataSet.datetimeFormat. Please refer to datetimeFormat help topic about the details. 

In the code below, it has set the conversion format as "yyyy/MM/dd HH:mm:ss"

Code -1
    dsMain = DataLudi.createGridDataSet();
    dsMain.setFields(fields);
    dsMain.setDatetimeFormat("yyyy/MM/dd HH:mm:ss");
Field1:Field2:Field3:Field4:
Field1.minimum:Field1.maximum:
Grid - 1
0 rows

2. Display Date Time Value in the data cell

DATETIME field value is displayed in the data cell according to the specified format in datetimeFormat of GridStyles. Please refer to GridStyles.datetimeFormat help topic about the details of display format. 

In the example below, it displays the format in the column header. 

Grid - 2
0 rows

View Source JSP 

See Also
Data Field Overview
ValueType
DataField.datetimeFormat
DataSet.datetimeFormat
GridStyles.datetimeFormat
Date
Examples
Number Value
Boolean Value
Object Field