【问题标题】:Flash builder: How to get selected Cell value in datagrid?Flash builder:如何在数据网格中获取选定的单元格值?
【发布时间】:2012-04-05 00:03:04
【问题描述】:

我有一个可编辑的数据网格。我想知道用户编辑单个单元格后是否可以检索单元格值。

如果用户完成编辑,我的数据网格将触发griditemEditorSessionSave 事件,但我不知道如何获取新的单元格值。

//script
protected function dg_gridItemEditorSessionSaveHandler(event:GridItemEditorEvent):void
  {
     //I can only get the columnIndex but not the value
      Alert.show (event.columnIndex);

  } 

//mxml

<s:DataGrid id="dg" editable="true" x="5" y="3" width="734" height="153"
                  gridItemEditorSessionSave="dg_gridItemEditorSessionSaveHandler(event)"
>
....
.....

</Datagrid>

有什么想法吗?非常感谢。

【问题讨论】:

  • 我还没有机会使用 Spark DataGrid。但是,当该事件被调度时,已编辑的项目已保存回您的 dataProvider。您可以使用事件的rowIndex 属性来获取dataProvider 中项目的索引。并使用columnIndex 推断该项目的哪个属性被编辑。另一个想法是检查event.target - 不确定这是否是已编辑单元格的渲染器,或者可能是 dataGrid 本身...

标签: flash datagrid flash-builder


【解决方案1】:

是的,这是可能的..就在最近我遇到了同样的问题。我很熟悉这个主题中没有太多的 As3 文档,因此或多或少只是初始化 DataGrid 并填充它,因此;不抓住价值本身。

在我的 Datagrid 上,我发现每次编辑整个 dataGrid 时都更容易保存它,因为我没有找到为每个单独的单元格执行此操作的方法。就像用逗号分隔值的文本文件一样

使用循环函数遍历每个数组的长度,列/行,如果您需要此项目的完整源代码,请转到:

http://ffiles.com/flash_files/3559/index.html

【讨论】:

    猜你喜欢
    • 2012-03-09
    • 1970-01-01
    • 2013-08-09
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-04-19
    • 1970-01-01
    • 2019-12-31
    相关资源
    最近更新 更多