如何使 DatePicker 中的日期不可选择?
我在想如何只启用一周中的某些天?例如如何使某月某一周的周一、周三、周四启用,其余日期禁用?
我已经尝试过 setDate(DateOption dateOption) 、 setMaxDate(DateOption dateOption) 和 setMinDate(DateOption dateOption) 但没有结果。
谢谢。
I was wandering how to make only some days in a week enabled? For example how to make Monday Wednesday and Thursday enabled and the rest of the days disabled in a certain week in a certain month?
I have played around with setDate(DateOption dateOption)
, setMaxDate(DateOption dateOption)
, and setMinDate(DateOption dateOption)
but with no result.
Thank you.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
AFAIK 你不能用默认的 jQuery 日期选择器来做到这一点。
我最近自己遇到了这个问题,我无法使用默认的 jQuery datepicker 找到解决方案,所以我使用以下方法创建了自己的 wiQuery 插件: http://keith-wood.name/datepick.html。它需要更多的工作,但是通过深入研究 wiQuery 代码,您可以找到需要模拟的类来让这个备用日期选择器工作。
我
从 org.odlabs.wiquery.ui.datepicker
.classes。我将“Multi”附加到这些类名的开头,并使用了设置和回调选项的参考指南: http://keith-wood.name/datepickRef.html(也可以通过单击第一个链接中的快速参考来查看更简洁但不太简洁的版本),使我新创建的 MultiDatePicker 类能够生成正确的 javascript。
例如,默认情况下,DatePicker 中有以下代码:
用于创建以下 javascript:
(其中我选择的选项位于大括号内)。
我在 MultiDatePicker.java 中将其更改为:
我将以下行:
放入我的 multiDatePickerOptions 中,并在 MultiDatePicker 类中设置了一些愚蠢的 getter 和 setter 来设置这些选项,这允许您设置可以设置多少个日期。通过完成所有这些,我能够做到:
生成以下 javascript 代码:
祝你好运!
AFAIK you cannot do this with the default jQuery datepicker.
I recently came across this problem myself, I could not find a solution using the default jQuery datepicker, so instead I created my own wiQuery plugin using: http://keith-wood.name/datepick.html. It requires a little more work, but by digging into the wiQuery code, you can find the classes you need to emulate to get this alternate datepicker working.
I copied the:
.classes from org.odlabs.wiquery.ui.datepicker.
I appended 'Multi' to the beginning of these class-names and used the reference guide of settings and callback options at: http://keith-wood.name/datepickRef.html (can also see a neater but less concise version by clicking quick ref from the first link) to enable my newly created MultiDatePicker class to generate the correct javascript.
For example, by default in DatePicker there is the following code:
Which is used to create the following javascript:
(where my chosen options are within the curly braces).
I changed this in my MultiDatePicker.java to:
I placed the lines:
into my multiDatePickerOptions, and some dumb getters and setters in the MultiDatePicker class which set these options, and this allows you to set how many dates can be set. By doing all this I was then able to do:
Which generates the following javascript code:
Good luck!