DateChooser..禁用年份和月份?

发布于 2024-09-12 20:23:01 字数 169 浏览 6 评论 0原文

我想要使​​用 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 技术交流群。

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

发布评论

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

评论(4

七颜 2024-09-19 20:23:01

这是禁用月份选择箭头的方法...彻底的 CSS hack!

nextMonthUpSkin: ClassReference('mx.skins.Border');
nextMonthDisabledSkin: ClassReference('mx.skins.Border');
nextMonthDownSkin: ClassReference('mx.skins.Border');
nextMonthOverSkin: ClassReference('mx.skins.Border');
prevMonthUpSkin: ClassReference('mx.skins.Border');
prevMonthDisabledSkin: ClassReference('mx.skins.Border');
prevMonthDownSkin: ClassReference('mx.skins.Border');
prevMonthOverSkin: ClassReference('mx.skins.Border');   

我很抱歉八月份没有看到这个问题。但我最近(昨天)遇到了同样的问题并找到了这个解决方案......干杯。

Here is how you disable the month selection arrows...a total CSS hack!!

nextMonthUpSkin: ClassReference('mx.skins.Border');
nextMonthDisabledSkin: ClassReference('mx.skins.Border');
nextMonthDownSkin: ClassReference('mx.skins.Border');
nextMonthOverSkin: ClassReference('mx.skins.Border');
prevMonthUpSkin: ClassReference('mx.skins.Border');
prevMonthDisabledSkin: ClassReference('mx.skins.Border');
prevMonthDownSkin: ClassReference('mx.skins.Border');
prevMonthOverSkin: ClassReference('mx.skins.Border');   

I apologize for not seeing this question in August. But I recently (yesterday) had the same problem and found this solution...cheers.

深海夜未眠 2024-09-19 20:23:01

正如 JabbyPanda 提到的,您可以扩展 DateChooser 控件。只需很少的额外工作,您就可以获得理想且更可重用的实现,但我们在这里坚持简单性。因此,您所需要做的就是删除 fwdMonthButtonbackMonthButton,或者通过将visible 属性设置为 false 来隐藏它们。例如:

import mx.controls.DateChooser;
import mx.core.mx_internal;
use namespace mx_internal;

public class MyDateChooser extends DateChooser
{
    override protected function createChildren():void {
        super.createChildren();
        // Remove them:
        this.removeChild(this.mx_internal::fwdMonthButton);
        this.removeChild(this.mx_internal::backMonthButton);
        // Or just hide them:
        //this.mx_internal::fwdMonthButton.visible = false; 
        //this.mx_internal::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 and backMonthButton, or hide them by setting the visible property to false. For example:

import mx.controls.DateChooser;
import mx.core.mx_internal;
use namespace mx_internal;

public class MyDateChooser extends DateChooser
{
    override protected function createChildren():void {
        super.createChildren();
        // Remove them:
        this.removeChild(this.mx_internal::fwdMonthButton);
        this.removeChild(this.mx_internal::backMonthButton);
        // Or just hide them:
        //this.mx_internal::fwdMonthButton.visible = false; 
        //this.mx_internal::backMonthButton.visible = false;    
    }
}
心在旅行 2024-09-19 20:23:01

您还可以使用selectableRange属性并适当地设置rangeStartrangeEnd。仅允许用户选择 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.

寂寞美少年 2024-09-19 20:23:01

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"

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