[英]set the max date on kendo date picker from client side
I have this:我有这个:
var today = new Date();
Updating the kendo datepicker:更新剑道日期选择器:
$('#datepicker').kendoDatePicker({
max: today.setDate(today.getDate()+30);
});
In the debugger the max value is 1404408808080
but in today variable the date is right one 2014-07-03T17:3
.在调试器中,最大值是
1404408808080
但在今天变量中,日期是正确的2014-07-03T17:3
。 Want to set the max date for kendodatepicker 30 days from the current date.想要将 kendodatepicker 的最大日期设置为距当前日期 30 天。
You have to use the setOptions()
method to change that:你必须使用
setOptions()
方法来改变它:
var datepicker = $("#datepicker").data("kendoDatePicker");
datepicker.setOptions({
max: new Date(today.setDate(today.getDate()+30))
});
Or if you want just do this in the initialization:或者,如果您只想在初始化中执行此操作:
$("#datepicker").kendoDatePicker({
max: new Date(today.setDate(today.getDate()+30))
});
The setDate
function returns the date as an integer (the long number you posted); setDate
函数以整数形式返回日期(您发布的长数字); try sending that as a parameter to a new Date object, like so:尝试将其作为参数发送到新的 Date 对象,如下所示:
$('#datepicker').kendoDatePicker({
max: new Date(today.setDate(today.getDate()+30));
});
It worked this way also它也以这种方式工作
var today = new Date();
var maxDate = today.setDate(today.getDate()+30);
$('#datepicker').kendoDatePicker({
max: new Date(maxDate) });
I think this is the simplest way (as per Kendo document too)我认为这是最简单的方法(也根据Kendo文档)
<input id="datepicker" />
<script>
$("#datepicker").kendoDatePicker();
var datepicker = $("#datepicker").data("kendoDatePicker");
datepicker.max(new Date(2100, 0, 1));
</script>
Added a dojo example where see how we restrict (minimum and maximum date example) the birthdate and deceased date of a patient entry.添加了一个道场示例,其中查看我们如何限制(最小和最大日期示例)患者条目的出生日期和死亡日期。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.