dijit 日历在 dojo 中仅显示从当天开始的 52 周后
dijit calendar to display only 52 weeks back from current day in dojo
我需要在 dojo 中显示从当天开始仅 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>
这很简单,您必须以编程方式完成,
创建一个日历 dijit,然后通过检查 show cal view days are > or are week days 来覆盖其 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>
我需要在 dojo 中显示从当天开始仅 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>
这很简单,您必须以编程方式完成,
创建一个日历 dijit,然后通过检查 show cal view days are > or are week days 来覆盖其 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>