带有itemEditor的AdvancedDatagrid:单击时值将消失

时间:2015-12-22 14:00:39

标签: actionscript-3 flex flash-builder4.5

我试图在AdvancedDatagrid中使用ComboBox作为itemEditor。 grid和comboBox都正确填充值。但是当我点击一个单元格时,该值就会消失。我是否需要设置更多属性才能使其工作,或者我是否必须编写自己的itemEditor来将值复制到itemEditor或从itemEditor复制值?

完整代码:

<?xml version="1.0"?>
<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" 
               initialize="initCB();">

<fx:Script>
    <![CDATA[
        import mx.collections.*;
        [Bindable] public var stateArray:ArrayCollection;

        public function initCB():void {
            stateArray=new ArrayCollection([{label:"AL", data:"Montgomery"},
                                      {label:"AK", data:"Juneau"},
                                      {label:"AR", data:"Little Rock"}]);
        } 

        [Bindable] public var initDG:ArrayCollection = new ArrayCollection([{etikett:'NY', tekst:"New York"}, {etikett:'CA', tekst:"Los Angeles"}]);
    ]]>
</fx:Script>     


<mx:AdvancedDataGrid id="gridIntMapping" y="24" left="10" right="605" height="166" editable="true" dataProvider="{initDG}">
    <mx:columns>
            <mx:AdvancedDataGridColumn width="130" dataField="etikett" headerText="Skjema referanse" editorDataField="text">
                <mx:itemEditor>
                    <fx:Component>                  
                        <mx:ComboBox editable="true" dataProvider="{outerDocument.stateArray}" labelField="label"/>
                    </fx:Component>
                </mx:itemEditor>
            </mx:AdvancedDataGridColumn>
    </mx:columns>
</mx:AdvancedDataGrid>

1 个答案:

答案 0 :(得分:0)

data.etikett设置为组合框文本。如下:

<mx:ComboBox editable="true" dataProvider="{outerDocument.stateArray}" labelField="label" text="{data.etikett}" />

点击时会显示文字。