Last active
October 7, 2015 02:58
-
-
Save rjattrill/3094094 to your computer and use it in GitHub Desktop.
Format Date in DataGrid
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<fx:Declarations> | |
<s:DateTimeFormatter id="dateTimeFormatter" dateTimePattern="yyyy-MM-dd"/> | |
</fx:Declarations> | |
<s:DataGrid id="dg" height="100%" width="100%" borderVisible="false"> | |
<s:columns> | |
<s:ArrayList> | |
<s:GridColumn dataField="Date" headerText="Date" formatter="{dateTimeFormatter}"/> | |
</s:ArrayList> | |
</s:columns> | |
</s:DataGrid> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<fx:Script> | |
<![CDATA[ | |
import spark.formatters.DateTimeFormatter; | |
private function formatDate (item:Object, column:GridColumn):String { | |
var df:DateTimeFormatter = new DateTimeFormatter(); | |
df.dateTimePattern = "dd-MMM-yyyy"; | |
var value:Object = item[column.dataField]; | |
return df.format(value); | |
} | |
]]> | |
</fx:Script> | |
<s:DataGrid id="dg" height="100%" width="100%" borderVisible="false"> | |
<s:columns> | |
<s:ArrayList> | |
<s:GridColumn dataField="TRAN_DATE" headerText="Transaction Date" labelFunction="formatDate"></s:GridColumn> | |
</s:ArrayList> | |
</s:columns> | |
</s:DataGrid> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment