可编辑列的值未在AdvancedDataGrid中“持久化”

时间:2012-07-13 19:32:58

标签: actionscript-3 flex actionscript

我有一个AdvancedDataGrid(其dataProvider是一个从我的主mxml文件绑定的变量,不确定这是否与我的问题相关)。我将AdvancedDataGridColumn的一个可编辑属性设置为true,当我单击UI中的单元格时,它实际上是可编辑的。但是当我按下Enter / move到另一个单元格时,旧值返回并且新输入的值将丢失。有人会有任何想法为什么会这样吗?我是否必须手动更改dataProvider中提供的变量?...我认为这会自动发生吗?我很感激任何帮助!

感谢。

1 个答案:

答案 0 :(得分:0)

当我编辑字段并按Enter键然后单击按钮以查看跟踪输出时,这会正确显示:

      <?xml version="1.0" encoding="utf-8"?>
      <s:Application xmlns:fx="http://ns.adobe.com/mxml/2009" 
               xmlns:s="library://ns.adobe.com/flex/spark" 
               xmlns:mx="library://ns.adobe.com/flex/mx" minWidth="955" minHeight="600" applicationComplete="init()">
        <fx:Declarations>
          <!-- Place non-visual elements (e.g., services, value objects) here -->
        </fx:Declarations>
        <fx:Script>
          <![CDATA[
            import mx.collections.HierarchicalData;
            [Bindable]
            private var companyHierarchy:HierarchicalData;

            private var companyData:XML = <data>
                        <company name="Employees">
                          <department name="Unit 1">
                            <employee name="Dave" func="C# Developer"/>
                            <employee name="Bob" func="AS3 Developer"/>
                            <employee name="Clair" func="AS3 Architect"/>
                          </department>
                          <department name="Unit 2">
                            <employee name="John" func="ORACLE Developer"/>
                            <employee name="Sandra" func="HTML Developer"/>
                          </department>
                        </company>
                      </data>;


            private function init():void
            {
              companyHierarchy = new HierarchicalData(companyData.company);
            }

            private function checkSetData():void
            {
              trace(companyData);
            }
          ]]>
        </fx:Script>
        <mx:AdvancedDataGrid id="test" width="500" height="500" dataProvider="{companyHierarchy}"
                   displayItemsExpanded="true" editable="true" enabled="true">
          <mx:columns>
            <mx:AdvancedDataGridColumn dataField="@name"
                           headerText="Companies"/>
            <mx:AdvancedDataGridColumn dataField="@func"
                           headerText="Function"/>
          </mx:columns>
        </mx:AdvancedDataGrid>
        <s:Button x="205" y="508" label="Button" click="checkSetData()"/>
      </s:Application>