DateChooser..禁用年份和月份?
我想要使用 DateChooser
来允许用户选择给定月份和年份中的日期。我想以编程方式设置月份和年份,并且只允许用户选择日期/日期。
我可以通过将 minYear 和 maxYear 设置为我想要的任何年份来轻松地完成这一年的操作,但我没有看到禁止用户选择不同月份的直接方法?
I want a to user a DateChooser
to allow a user to select a date in a given month and year. I want to set the month and year programmatically and only allow the user to select the date/day.
I can do this for the year easily by setting the minYear and maxYear to whatever year I want, but I am not seeing a strait forward way of disallowing the user to select a different month?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
这是禁用月份选择箭头的方法...彻底的 CSS hack!
我很抱歉八月份没有看到这个问题。但我最近(昨天)遇到了同样的问题并找到了这个解决方案......干杯。
Here is how you disable the month selection arrows...a total CSS hack!!
I apologize for not seeing this question in August. But I recently (yesterday) had the same problem and found this solution...cheers.
正如 JabbyPanda 提到的,您可以扩展 DateChooser 控件。只需很少的额外工作,您就可以获得理想且更可重用的实现,但我们在这里坚持简单性。因此,您所需要做的就是删除
fwdMonthButton
和backMonthButton
,或者通过将visible 属性设置为 false 来隐藏它们。例如:As mentioned by JabbyPanda, you could extend the DateChooser control. With little extra work you can get an ideal and more reusable implementation, but let's stick to simplicity here. So, all you need to do is to remove both
fwdMonthButton
andbackMonthButton
, or hide them by setting the visible property to false. For example:您还可以使用selectableRange属性并适当地设置rangeStart和rangeEnd。仅允许用户选择 2010 年 8 月 1 日至 2010 年 8 月 15 日的示例:
selectableRange="{{rangeStart:new Date(2010,7,1), rangeEnd:new Date(2010,7,15)}}"
但是,请注意,它仍然会显示月份导航器箭头(尽管它们已被禁用)。我不确定是否有一种简单的方法可以隐藏它们。
You could also use the selectableRange property and set rangeStart and rangeEnd appropriately. Example to only allow user to pick from Aug 1 2010 to Aug 15 2010:
selectableRange="{{rangeStart:new Date(2010,7,1), rangeEnd:new Date(2010,7,15)}}"
However, note it'll still show the month navigator arrows (though they're disabled). I'm not sure if there's an easy way to hide those.
mx:DateChooser 开箱即用仅允许通过公共属性“yearNavigationEnabled”禁用年份导航
如果您也想禁用月份导航,则必须从标准 DateChooser 组件扩展并实现类似于现有“yearNavigationEnabled”的“monthNavigationEnabled”功能
mx:DateChooser out of the box allows only disabling of year navigation by public property "yearNavigationEnabled"
If you would like to disable month navigation too, you will have to extend from standard DateChooser component and implement "monthNavigationEnabled" functionality similar to existing "yearNavigationEnabled"