gpt4 book ai didi

vaadin - 如何在 DateField 上定义禁用日期?

转载 作者:行者123 更新时间:2023-12-01 15:37:06 27 4
gpt4 key购买 nike

Scenario


I have a DateField for users to search old auction informations. But old auction informations can only search until yesterday. So , my DateField component will show yesterday date as default. Dates these were from today and later should be unselectable at my datefield.

为了满足以上条件,我设置了 setRangeEnd() 如下

    Calendar calendar = Calendar.getInstance();
calendar.add(Calendar.DATE, -1);
Date yesterday = new Date(calendar.getTimeInMillis());
PopupDateField auctionDate = new PopupDateField("Auction Date", yesterday);
auctionDate.setStyleName("auctiondatebox");
auctionDate.setDateFormat("dd/MM/yyyy");
auctionDate.setRangeEnd(yesterday);

并且我将超出范围天数的颜色设置为红色。

  .v-datefield-calendarpanel-day-outside-range {
color:red !important;
}

那很好,但我还有一个条件。每个星期日,拍卖都关闭。所以,用户不应该在我的日期字段中选择这些休息日(每个 星期日 都应该不可选择并且颜色显示为红色)
请有人给我建议如何在 DateField 中定义不可选择的日期.谢谢!

最佳答案

尝试使用 CSS。如果星期天是最后一列:

.v-datefield-calendarpanel-body  tr>td:last-child{
pointer-events: none;
color: red;
}

如果星期日列是第一列(在 vaadin 日期字段中第一列是隐藏的,因此星期日列是第二列):

.v-datefield-calendarpanel-body  tr>td:first-child + td{
pointer-events: none;
color: red;
}

关于vaadin - 如何在 DateField 上定义禁用日期?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26009736/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com