是否可以在 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').
推荐答案第一步:编写一个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]; }第二步:使用Primefaces datepicker的beforeShowDay属性
Step 2: use beforeShowDay attribute of Primefaces datepicker
<p:calendar id="pfdate" navigator="true" pattern="MM-dd-yyyy" value="#{day}" beforeShowDay="disableAllTheseDays" showOn="button"/>更多推荐
禁用 p:calendar 上的特定日期
发布评论