apache-flex - 如何将货币格式化程序放入 Flex 数据网格列中?

标签 apache-flex flash datagrid adobe format

我需要使用货币格式化程序来格式化该列。我知道如何进行货币格式化,我只需要一个有关如何将其实现到数据网格列中的示例。

最佳答案

无需使用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/

相关文章:

flash - 是什么导致 flash/actionscript 运行时错误 "WatcherSetupUtil is not defined"?

c# - DataGrid 列大小宽度适合单元格内容

actionscript-3 - Flex 数字微调器,要添加前面的 0

android - 适用于移动设备的 Adob​​e Air 中的表格组件

java - 如何在我的 spring bean 中获取 HttpServletRequest?

apache-flex - Flex 与 ActionScript

c++ - 脚本到二进制转换和对象序列化

ios - Action script 3.0 问题,我的 swf 无法卸载

c# - 绑定(bind)仅适用于第一个 TabItem

c# - 在编辑 WPF DataGrid 单元格期间显示弹出窗口