我需要在日历中显示距当前日期仅52周的日历,我同样使用dijit/Calendar
,有人可以通过提供仅显示距当前52周的光照来帮助我dijit日历中的一天。
当前,我正在使用data-dojo-props
,它仅禁用日历中的周末。
<div id="mycal" data-dojo-attachpoint="mycal"
data-dojo-type="dijit.calendar"
data-dojo-props="isDisabledDate:dojo.date.locale.isWeekend">
</div>
答案 0 :(得分:0)
这是如此简单,您必须以编程方式进行操作,
创建日历dijit,然后通过检查两个显示日历天是否为>或为工作日来覆盖其isDisabledDate
函数:如下
return dojoDate.difference(date, new Date(), "day") > disable_before_days || locale.isWeekend(date) ;
请参见下面的工作片段:
require(["dojo/parser",
"dijit/Calendar",
"dijit/registry",
"dojo/date",
"dojo/date/locale",
"dojo/ready",
"dojo/domReady!"
], function(parser, Calendar, registry, dojoDate, locale, ready){
disable_before_days = 52;
ready(function(){
//var calendar = registry.byId("mycal");
var calendar = new Calendar({
value: new Date(),
isDisabledDate:function(date, localString){
return dojoDate.difference(date, new Date(), "day") > disable_before_days
|| locale.isWeekend(date)
|| date > new Date() ;
}
}, "mycal");
});
});
html, body {
height: 100%;
padding: 0;
margin: 0;
font-family: Lucida Sans,Lucida Grande,Arial !important;
font-size: 13px !important;
background: white;
color: #333;
}
#mycal .dijitCalendarDisabledDate {
background-color: #333;
text-decoration: none;
}
#mycal .dijitCalendarContainer {
margin: 25px auto;
}
<link href="https://ajax.googleapis.com/ajax/libs/dojo/1.8.3/dojox/calendar/themes/claro/Calendar.css" rel="stylesheet"/>
<link href="https://ajax.googleapis.com/ajax/libs/dojo/1.8.3/dijit/themes/claro/claro.css" rel="stylesheet"/>
<script type="text/javascript">
dojoConfig = {
isDebug: true,
async: true,
parseOnLoad: true
}
</script>
<script src="https://ajax.googleapis.com/ajax/libs/dojo/1.10.4/dojo/dojo.js"></script>
<body class="claro">
<div id="mycal" ></div>
</body>