Flex - 以编程方式清除日期字段

发布于 2024-07-14 19:51:33 字数 369 浏览 7 评论 0原文

在用户选择日期后或通过代码设置 myDateField.selectedDate 后,我找不到任何方法以编程方式清除 DateField 控件。

文档仅说明如果用户再次选择日期如何清除它。

但是执行 myDateField.selectedDate = myDateField.selectedDate 不起作用

我已经尝试了所有明显的,myDateField.selectedDate = nullmyDateField.text = ""< /code> - 但似乎没有任何效果。

有人有什么想法吗?

I cannot find any way to clear a DateField control programmatically after either a user has selected a date, or after I set myDateField.selectedDate via code.

Documentation only states how to clear it if a user selects the date again.

But doing myDateField.selectedDate = myDateField.selectedDate doesn't work

I have tried all the obvious, myDateField.selectedDate = null, myDateField.text = "" - but nothing seems to be doing the trick.

Does anyone have any ideas?

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

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

发布评论

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

评论(2

鲸落 2024-07-21 19:51:33

我做了一个最小的测试示例:

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="horizontal">
    <mx:Script>
        <![CDATA[
        private function clearDate():void   {
            testField.selectedDate = null;
        }
        ]]>
    </mx:Script>
    <mx:DateField id="testField"/>
    <mx:Button label="Clear" click="clearDate();"/>
</mx:Application>

它似乎工作正常。 您确定您的代码中没有一些令人困惑的错误吗?

(顺便说一句,这是 FB 3.2 的情况,以防版本问题。)

I made a minimal test example:

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="horizontal">
    <mx:Script>
        <![CDATA[
        private function clearDate():void   {
            testField.selectedDate = null;
        }
        ]]>
    </mx:Script>
    <mx:DateField id="testField"/>
    <mx:Button label="Clear" click="clearDate();"/>
</mx:Application>

and it seems to work fine. Are you sure there isn't some baffling bug in your code?

(This is with FB 3.2 here, by the way, in case it is a version issue.)

苦妄 2024-07-21 19:51:33

它也适用于 FB2。

It works on FB2 too.

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