Skip to content

Instantly share code, notes, and snippets.

@rjattrill
Last active December 10, 2015 23:18
Show Gist options
  • Save rjattrill/4508160 to your computer and use it in GitHub Desktop.
Save rjattrill/4508160 to your computer and use it in GitHub Desktop.
Format numbers in Spark DataGrid
<fx:Script><![CDATA[
import spark.formatters.NumberFormatter;
var numberFormatter:NumberFormatter = new NumberFormatter();
private function numberFormat(item:Object, column:GridColumn):String {
return numberFormatter.format(item [column.dataField]);
}
]]>
</fx:Script>
<s:GridColumn dataField="valueNum" headerText="Value" labelFunction="numberFormat">
@rjattrill
Copy link
Author

You normally will have the labelFunction already in a base component.

@rjattrill
Copy link
Author

Another approach - probably simpler - is to use the 'formatter' property of the dataGrid and point it to a spark.formatter

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment