我需要使用货币格式化程序来格式化该列。我知道如何进行货币格式化,我只需要一个有关如何将其实现到数据网格列中的示例。
最佳答案
无需使用itemRenderer
。只需使用labelFunction
。示例:
DataGridColumn:
<mx:DataGridColumn headerText="Total Cost" dataField="TotalCost" labelFunction="LabelFormatter"/>
LabelFormatter标签函数:
protected function LabelFormatter(item:Object, column:DataGridColumn):String
{
var returnLabel:String = "";
var header:String = column.headerText;
switch (header)
{
case "Total Cost":
returnLabel = currencyFormat.format(item.TotalCost.toString());
break;
}
return returnLabel;
}
货币格式化程序:
<mx:CurrencyFormatter id="currencyFormat" precision="2" />
关于apache-flex - 如何将货币格式化程序放入 Flex 数据网格列中?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4805971/