本文介绍了在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上停用特定日期
发布评论