Flex3 中下拉日历内带有组合框和清除按钮的自定义 dateField 组件
我插入了一个 dateField 组件。单击后,它会显示日历。我想向日历添加 2 个组合框,一个显示小时(0 到 23),另一个显示分钟(0 到 59),以便用户可以选择时间和日期,并将其显示在文本中输入日期和时间。我想添加的另一件事是清除按钮,用于清除日历中选定的日期。
I inserted a dateField component. On clicking, it displays calendar. I would like to add 2 comboboxes, one shows hours (0 to 23) and other for minutes (0 to 59), to the calendar so that the user can select the time along with the date, and that will be displayed in the text input as date and time. One more thing I would like to add is clear button to clear the selected date in the calendar.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
既然 DateField 本质上是一个 TextInput 加上一个 DateChooser,为什么不自己做呢?还要添加两个 ComboBox,使 TextInput editable="false" text="{dateTime}" ,其中 dateTime 是您创建的可绑定字符串变量,作为 DateChooser 和两个 ComboBox 中的值的串联。调用在所有三个输入的更改事件上创建日期时间字符串的函数。
最后,添加您的清除按钮,并让它的单击事件调用一个函数,在该函数中将 DateChooser 设置为今天,将两个组合框设置为默认值,并根据需要更新日期时间字符串(根据需要更新为空白或当前日期/时间)你正在尝试做的事。)
编辑:
正如您提出的好意,而且我正在准备 ACE 考试,并认为这是一次很好的练习,这就是我的想法。我在名为“components”的包中制作了以下自定义组件,并将其命名为“myCustomDateField.mxml”。
在我的应用程序中,我在声明标记中添加了
xmlns:cust="components.*"
,并且插入了一个。
我能够使用{myDate.dateTime} 访问父级中的条目。
我做了您可能决定更改一些设计假设,例如格式化程序,我用 NumericStepper 替换了您的组合框。
Since a DateField is essentially a TextInput coupled with a DateChooser, why not do that yourself? Also add your two ComboBox, make your TextInput editable="false" text="{dateTime}" where dateTime is a Bindable string variable you create as the concatenation of the values in the DateChooser and the two ComboBox. Call the function that creates the dateTime string on the change event of all three inputs.
Finally, add your clear Button, and have its click event call a function where you set the DateChooser to today, and the two combo boxes to default values, and update dateTime string as needed (to blank or to current date/time depending on what you are trying to do.)
Edit:
As you asked nicely, and as I am studying for the ACE exam and thought this made a nice excercise, here is what I came up with. I made the following custom component in a package named 'components' and called it 'myCustomDateField.mxml'
In my application, I added the
xmlns:cust="components.*"
in the declaration tag, and inserted one<cust:myCustomDateFeild id="myDate" />.
I was able to access the entry in the parent by using{myDate.dateTime}.
I made a few design assumption that you may decide to change, like the formatter, and I replaced your combo boxes with NumericStepper.