从 mx:Repeater 内部获取 mx:CheckBox 值
我有一个对象数组,用作中继器的数据源。
<mx:Repeater id="categoryRepeater" dataProvider="{this.allCategories}">
<mx:HBox>
<mx:Spacer width="20"/>
<mx:CheckBox id="categoryCheckBox" label="{categoryRepeater.currentItem.question}"/>
</mx:HBox>
</mx:Repeater>
我希望能够知道列表中的哪些复选框已被选中,但我不知道该怎么做。 我知道我可以在单击时添加一个函数,但我不知道如何判断哪个复选框调用了该函数。
I have an an array of objects that I use as the datasource for my repeater.
<mx:Repeater id="categoryRepeater" dataProvider="{this.allCategories}">
<mx:HBox>
<mx:Spacer width="20"/>
<mx:CheckBox id="categoryCheckBox" label="{categoryRepeater.currentItem.question}"/>
</mx:HBox>
</mx:Repeater>
I would like to be able to tell which of the checkboxes in the list have been checked, but I'm not sure how to do it. I know I can add a function when it's clicked, but I don't know how to tell which checkbox called the function.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
使用
currentIndex
属性。Use the
currentIndex
property.我意识到这是一篇非常旧的帖子,但我遇到了同样的问题,并且 currentIndex 对我来说并不是一个足够的答案。 我发现效果更好的是在单击时创建一个函数:
showAlert 函数看起来像这样:
通过这种方式,您可以将事件作为 ActionScript 代码内的复选框来处理,并查找值,例如它是否已被选定等
I realize that this is a very old post, but I had run into the same issue and the currentIndex was not a sufficient answer for me. What I found to work better was to create a function on click:
and the showAlert function looks something like this:
This way you can deal with the event as a CheckBox inside of your ActionScript code and find values such as whether or not it has been selected etc.