Flex:将参数传递给itemEditor

时间:2010-07-19 07:54:32

标签: flex datagrid

我有一个数据网格,其中一列调用自定义的itemEditor,如;

                    <mx:DataGridColumn dataField="city"
                                       width="150" 
                                       headerText="City" 
                                       itemEditor="components.ComboCity" 
                                       editorDataField="city"/>

我的自定义itemEditor看起来像;

    <?xml version="1.0" encoding="utf-8"?>
    <s:MXDataGridItemRenderer xmlns:fx="http://ns.adobe.com/mxml/2009" 
                              xmlns:s="library://ns.adobe.com/flex/spark" 
                              xmlns:mx="library://ns.adobe.com/flex/mx" 
                              focusEnabled="true">
        <mx:ComboBox id="comboBox"/>
        <fx:Script>
            <![CDATA[
                public var myString:String;
                .
                .
                .

如何从主应用程序传递值myString

3 个答案:

答案 0 :(得分:2)

看一下这个链接,我想你会在那里找到答案:

http://livedocs.adobe.com/flex/3/html/help.html?content=cellrenderer_3.html

Furher xp:

  myGrid.editedItemRenderer.data.City=myEditor(myGrid.itemEditorInstance).setCity.text;

答案 1 :(得分:1)

对我来说最好的解决方案:

<mx:Script>
    <![CDATA[

        import mx.events.DataGridEvent;

        private function itemEditorCreateHandle(event:DataGridEvent):void
        {               
            ComboCity(DataGrid(event.target).itemEditorInstance).myString = "Put here the value";
        }   

    ]]>
</mx:Script>

<mx:DataGridColumn      
    dataField="city"
    width="150" 
    headerText="City" 
    itemEditor="components.ComboCity" 
    itemEditorCreate="itemEditorCreateHandle(event);" 
    editorDataField="city"/>

答案 2 :(得分:0)

您始终可以通过调用“outerDocument”属性来引用itemRenderer中的父组件,例如:

myString = outerDocument.componentProperty

http://livedocs.adobe.com/flex/3/html/help.html?content=cellrenderer_6.html