简体   繁体   English

从客户端设置剑道日期选择器的最大日期

[英]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.

相关问题 剑道日期选择器最大日期 - Kendo Date Picker Max Date 如何在日期选择器中设置最大日期? - How to set max date in date picker? 将RadDatePicker客户端的最小/最大日期设置为从今天起的30天? - Set RadDatePicker client-side Min/Max dates to to 30days from todays date? Kendo AngularJS日期选择器-如何将ng-model从时间戳设置为格式化日期? - Kendo AngularJS Date picker - how to set ng-model from timestamp to formatted date?He 剑道日期选择器选择日期应从年份开始 - Kendo Date Picker Selecting Date should start from years Kendo Date-Picker的正则表达式日期字符串/值 - Regex Date String/Value from Kendo Date-Picker DateEdit在客户端设置日期值 - DateEdit set a date value on the client side 如何在第一个日期选择器选择DATE时在第二个日期选择器中设置DATE? - How to set DATE in second date-picker on selection of DATE from first date-picker? 如何使用Clean jQuery Date and Time Picker Plugin设置从一个选择器到另一个选择器的日期-datetimepicker - How to set a date From one picker to another picker using Clean jQuery Date and Time Picker Plugin - datetimepicker 从客户端的mongo _id中提取日期 - Pull date from mongo _id on the client side
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM