Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/apache-flex/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Apache flex 使用复选框在Itemrenderer中选择不正确_Apache Flex - Fatal编程技术网

Apache flex 使用复选框在Itemrenderer中选择不正确

Apache flex 使用复选框在Itemrenderer中选择不正确,apache-flex,Apache Flex,我使用“Tilelist”和“HBOX”作为项目渲染器。在HBOX中,我有复选框 将arraycollection作为数据提供程序传递给TileList(我的arraycollection长度为20)。在Tilelist中选中item1复选框并滚动列表时,我可以看到从item1开始的后续项目被选中。在博客中,我发现在使用复选框时存在flex缓存问题 我需要一些帮助 先谢谢你 <?xml version="1.0" encoding="UTF-8" standalone="no"?>

我使用“Tilelist”和“HBOX”作为项目渲染器。在HBOX中,我有复选框

将arraycollection作为数据提供程序传递给TileList(我的arraycollection长度为20)。在Tilelist中选中item1复选框并滚动列表时,我可以看到从item1开始的后续项目被选中。在博客中,我发现在使用复选框时存在flex缓存问题

我需要一些帮助

先谢谢你

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" verticalGap="0" xmlns:local="*" height="500" >
    <mx:Script>
    <![CDATA[
        private var arr:Array = [
            { firstName: "Alex", lastName: "Harui" },
            { firstName: "Gordon", lastName: "Smith" },
            { firstName: "Deepa", lastName: "Subramanian" },
            { firstName: "Matt", lastName: "Chotin" },
            { firstName: "Ely", lastName: "Greenfield" },
            { firstName: "Kevin", lastName: "Lynch" },
            { firstName: "Shantanu", lastName: "Narayan" },
            { firstName: "Joan", lastName: "Lafferty" },
            { firstName: "Ryan", lastName: "Frishberg" },

        ];

    ]]>
    </mx:Script>
     <mx:TileList id="list" initialize="list.dataProvider=arr" labelField="lastName" maxColumns="1" itemRenderer="Checkrenderer" 
                allowMultipleSelection="true" >

    </mx:TileList> 
</mx:Application>

Checkrender HBOX:

<?xml version="1.0" encoding="utf-8"?>
<mx:HBox xmlns:mx="http://www.adobe.com/2006/mxml" width="138" height="300" xmlns:local="*">
<mx:CheckBox id="checkbx"/>
</mx:Box>
</mx:HBox>

基本上,您需要跟踪数据提供程序中数据的选定值,这是因为项目呈现器是“回收”的,这意味着它们与应用的不同数据一起重复使用,以便跟踪给定行的实际选定值,它需要附加到与该行关联的数据。您可以使用以下示例中提供的名为ValueObjectWithSelected的类I,通过将其指定给value属性来“包装”任何其他VO/DTO,selected属性用于跟踪复选框选择,并且当选中的复选框值更改时,渲染器设置此属性

要解决您的特定情况,请执行以下操作:

<?xml version="1.0" encoding="utf-8"?>
<mx:HBox xmlns:mx="http://www.adobe.com/2006/mxml" width="138" height="300" xmlns:local="*">
    <mx:CheckBox id="checkbx" label="{data.firstName}" change="{data.selected = checkbx.selected}" selected="{data.selected}"/>
</mx:HBox>


是否使用项目渲染器?你能发布你的代码吗?您可能需要重写
公共函数集数据(值:Object)
检查呈现程序代码:您应该在问题中而不是在注释中发布代码,这会导致无法读取和难以复制。。。。将代码粘贴到问题区域,然后突出显示代码并单击堆栈溢出编辑器上方的{}按钮。我几乎可以肯定,我可以回答这个问题,没有代码,因为这是许多其他人试图做的事情。。。我会看看我是否能足够快地把一个例子放在一起,这样我就可以参考它,而不是试图解释这一点或指向其他答案。您可以突出显示您的代码,然后按该键对其进行格式化,使其正确显示在问题中。我通过编辑您的问题为您修复了代码格式。