在p:calendar上停用特定日期

编程入门 行业动态 更新时间:2024-10-09 08:25:54
本文介绍了在p:calendar上停用特定日期的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

是否可以在PrimeFaces 3.5 < p:calendar> 组件上禁用特定日期(例如:5月15日或6月23日)有最小和最大值,但我需要禁用公共假期等使用el表达式的特定日期,以便我可以使用动态日期。

Is it possible to disable specific dates (for example: 15th May or 23rd June) on the PrimeFaces 3.5 <p:calendar> component? There is min and max, but I need to disable specific dates like public holidays using el expressions so I can use dynamic dates.

使用Hieu回答,请确保您禁用的日期前面没有前导零(例如'03 / 03/2013'应为'3/3/2013')。

Using Hieu's answer, make sure the dates you disable have NO leading zeros in front (eg. '03/03/2013' should be '3/3/2013').

推荐答案

步骤1:写一个javascript函数来禁用日期列表

Step 1: write a javascript function to disable a list of dates

var disabledDays = ["5-15-2013", "6-23-2013"]; function disableAllTheseDays(date) { var m = date.getMonth(), d = date.getDate(), y = date.getFullYear(); for (i = 0; i < disabledDays.length; i++) { if($.inArray((m+1) + '-' + d + '-' + y,disabledDays) != -1) { return [false]; } } return [true]; }

步骤2:使用 beforeShowDay

<p:calendar id="pfdate" navigator="true" pattern="MM-dd-yyyy" value="#{day}" beforeShowDay="disableAllTheseDays" showOn="button"/>

更多推荐

在p:calendar上停用特定日期

本文发布于:2023-11-24 12:06:08,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1625133.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:日期   calendar

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!