radioButtonGroup 中的所有 radioButton 均被选中
您好,
我在组件 mxml 中有一个列表,如下所示:
<s:VGroup>
<s:Label text="TESTING" textDecoration="underline"/>
<s:List id="recouvrementModulesList" itemRenderer="renderers.ListRenderer">
<s:dataProvider>
<s:ArrayList>
<fx:String>Test</fx:String>
<fx:String>Test2</fx:String>
<fx:String>Test3</fx:String>
</s:ArrayList>
</s:dataProvider>
</s:List>
</s:VGroup>
我的 ListRenderer itemrenderer 如下:
<?xml version="1.0" encoding="utf-8"?>
<s:ItemRenderer xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx"
autoDrawBackground="true">
<fx:Script>
<![CDATA[
]]>
</fx:Script>
<fx:Declarations>
<mx:RadioButtonGroup id="rbg" />
</fx:Declarations>
<s:HGroup horizontalAlign="center" verticalAlign="middle">
<mx:RadioButton id="rb" group="{rbg}" label="{data}"/>
</s:HGroup>
</s:ItemRenderer>
请注意,itemrenderer 中的单选按钮属于“rbg”组。在此示例中,列表显示 3 行(因此每行有 3 个单选按钮)。但是,当我每次选择单选按钮时,允许对所有单选按钮进行选择。从逻辑上讲,如果它属于一个组,则应该只允许 1 个选择,但事实并非如此。
有人可以帮忙解决这个问题吗?
谢谢
Hello,
I have a list in a component mxml which is as follows:
<s:VGroup>
<s:Label text="TESTING" textDecoration="underline"/>
<s:List id="recouvrementModulesList" itemRenderer="renderers.ListRenderer">
<s:dataProvider>
<s:ArrayList>
<fx:String>Test</fx:String>
<fx:String>Test2</fx:String>
<fx:String>Test3</fx:String>
</s:ArrayList>
</s:dataProvider>
</s:List>
</s:VGroup>
My ListRenderer itemrenderer is as follows:
<?xml version="1.0" encoding="utf-8"?>
<s:ItemRenderer xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx"
autoDrawBackground="true">
<fx:Script>
<![CDATA[
]]>
</fx:Script>
<fx:Declarations>
<mx:RadioButtonGroup id="rbg" />
</fx:Declarations>
<s:HGroup horizontalAlign="center" verticalAlign="middle">
<mx:RadioButton id="rb" group="{rbg}" label="{data}"/>
</s:HGroup>
</s:ItemRenderer>
Notice that the radiobutton in the itemrenderer belong to the group "rbg". In this example the List appears with 3 rows (hence 3 radioButtons on each row). However when I selected the radioButtons, each at a time, the selection is allowed to be done for all radioButtons. Logically if it belongs to a group, it should allow only 1 selection, but it is not the case.
Can anyone please help on this issue?
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
使用设置数据方法:
Use set data method :
尝试将名称属性添加到单选按钮定义中。它的遗漏可能会导致按钮被单独对待,而不是作为一个整体。
Try adding a name attribute to the radio button definition. Its omission could be causing the buttons to be treated individually and not as a single unit.