Apache flex 在TextInput中编辑的值在滚动时折叠,该值在DataGrid中用作itemRenderer

Apache flex 在TextInput中编辑的值在滚动时折叠,该值在DataGrid中用作itemRenderer,apache-flex,datagrid,itemrenderer,textinput,Apache Flex,Datagrid,Itemrenderer,Textinput,我有两个数据网格1。选项网格和2。选举网格。我使用VBox容器作为选举网格中的itemRenderer,该网格由描述列中的TextInput组成。以下是SWF示例 无论何时在选项网格中选中复选框,我都必须为所有行在第二个网格(选择网格)中添加一个相应的文本输入,其中包含描述值。假设选择了两个复选框,我必须在第二个网格中添加两个textinput,以此类推。。。这很好用。但每当我编辑textinput并向上或向下滚动时,该值就会在行之间折叠或消失。 我怀疑在滚动时,ItemRenders将被重新用

我有两个数据网格1。选项网格和2。选举网格。我使用VBox容器作为选举网格中的itemRenderer,该网格由描述列中的TextInput组成。以下是SWF示例

无论何时在选项网格中选中复选框,我都必须为所有行在第二个网格(选择网格)中添加一个相应的文本输入,其中包含描述值。假设选择了两个复选框,我必须在第二个网格中添加两个textinput,以此类推。。。这很好用。但每当我编辑textinput并向上或向下滚动时,该值就会在行之间折叠或消失。 我怀疑在滚动时,ItemRenders将被重新用于其他行。如何在textinput中保留编辑的值

下面是代码

主要代码:

<mx:VBox width="100%" height="100%">
    <mx:Label text="OPTION GRID :" fontSize="12" fontStyle="normal" fontThickness="15"/>        
    <components:CAEventDetailDataGrid width="100%" height="20%" dataProvider="{optionData}" allowMultipleSelection="true" optionSelected="onOptionSelection(event)">        
        <components:columns>
            <mx:DataGridColumn dataField="selected" headerText="Select All" itemRenderer="renderer.CheckBoxItemRenderer" width="70" textAlign="center"/>
            <mx:DataGridColumn dataField="optionId" headerText="Option" textAlign="left"/>
            <mx:DataGridColumn dataField="option" headerText="Description" textAlign="left"/>
        </components:columns>       
    </components:CAEventDetailDataGrid>
    <mx:Label text="ELECTION GRID :" fontSize="12" fontStyle="normal" fontThickness="15"/>
    <mx:DataGrid id="electionGrid" width="100%" height="30%" dataProvider="{electionSummary}" rowCount="3" verticalScrollPolicy="on" variableRowHeight="true">                      
        <mx:columns>
            <mx:DataGridColumn dataField="dbProduct" headerText="DB Product"/>
            <mx:DataGridColumn dataField="entitledQty" headerText="Entitled Quantity"/>
            <mx:DataGridColumn dataField="entityId" headerText="Entity Id"/>
            <mx:DataGridColumn dataField="entityName" headerText="Entity Name"/>
            <mx:DataGridColumn dataField="eventStatus" headerText="Event Status"/>              
            <mx:DataGridColumn dataField="option" headerText="Description" itemRenderer="renderer.TextInputRenderer"/>            
        </mx:columns>                   
    </mx:DataGrid>
</mx:VBox>

<mx:Script>
    <![CDATA[
        import event.ElectionEvent;


        private function onOptionSelection(electionEvent : ElectionEvent) : void
        {       
            electionGrid.dispatchEvent(new ElectionEvent(ElectionEvent.OPTION_SELECTED,electionEvent.item));
        }

    ]]>
</mx:Script>
选择事件是一个自定义事件,每当在选项网格中选中/取消选中复选框时,将触发并调用侦听器函数addTextInput

private function addTextInput(electionEvent : ElectionEvent) : void
它们是在TextInput中保留编辑值的一种方法吗?有人能找到解决办法吗

我怀疑ItemRenders会 重新用于其他行,同时 滚动。如何保留已编辑的文档 文本输入中的值

更正itemRenderer的全部用途是在滚动基于列表的类时重用它。它不会渲染类中的所有数百个项目,而是只渲染您正在显示的4-10(或任何内容);并在滚动浏览时重复使用这些DisplayObject

您的代码看起来像是在向单个itemRenderer添加一个新的TextInput,但很难说。您忘记包含应用程序的链接

如何在中保留已编辑的值 文本输入


通常将值存储在对象的数据提供程序中;不会基于某些外部事件对其进行更改。因此,在“onItemSelect”方法中,您将向第二个DataGrid的数据中添加一项,这将创建一个新的渲染器,该渲染器应该能够通过该渲染器的data属性“创建自己”。

我修改了TextInputRenderer.as中的set data方法以显示编辑的文本。@Eswaran这解决了您的问题吗?或者帮你解决问题?
private function addTextInput(electionEvent : ElectionEvent) : void