Flex:RadioButtonGroup 上的验证器

发布于 2024-09-29 15:31:11 字数 602 浏览 1 评论 0原文

我在包含 2 个单选按钮的 RadioButtonGroup 上有一个验证器。 RadioButtonGroup 上方有一个复选框,如果 checkbox.Selected,则启用单选按钮。 因此,如果 checkbox.Selected 则需要验证器。到目前为止,一切都很好。

问题是一旦选择了radio,RadioButtonGroup selectedValue 就会被设置。当我取消选中该复选框时,我将单选按钮设置为未选中,但 RadioButtonGroup 上的 selectedValue 不会重置 - 它保留以前的值。我尝试将其设置为 null 但没有成功。

因此,如果我再次选中该复选框并提交,验证器会在 RadioButtonGroup 上看到 selectedValue。即使没有选择任何无线电,验证也会通过。

当我取消选中复选框时,如何将 RadioButtonGroup 重置为其初始状态?
谢谢。


聚苯乙烯 我查看了 RadioButtonGroup.selectedValue = null 的底层代码,它的作用是在参数值中查找单选按钮。如果没有找到,则不会设置任何内容。

I have a Validator on a RadioButtonGroup of 2 Radios. There's a checkbox above the RadioButtonGroup whereby if checkbox.Selected, then the Radios are enabled.
So the Validator is required if the checkbox.Selected. So far so good.

The problem is once a radio gets selected, the RadioButtonGroup selectedValue gets set. When I uncheck the checkbox I set the radios to not selected, but the selectedValue on the RadioButtonGroup doesn't get reset -- it hold the previous value. I tried setting it to null but no luck.

Therefore if I check the checkbox again and submit, the Validator see a selectedValue on the RadioButtonGroup. Even though none of the radios are selected, validation passes.

How can I reset the RadioButtonGroup to its initial state when I uncheck the CheckBox?
Thanks.


PS
I looked at the underlying code for RadioButtonGroup.selectedValue = null, and what it does is look for a radio in the with the parameter value. If it doesn't find it nothing gets set.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

七度光 2024-10-06 15:31:11

RadioButtonGroup.selection 是否有同样的问题?如果没有,我建议改用它。

Does RadioButtonGroup.selection have the same problem? If not, I'd suggest using that instead.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文