是否可以在 Kendo UI 日期选择器中过滤可选择的日期?

Is it possible to filter the selectable days in the Kendo UI datepicker?

有谁知道是否可以传入天数数组来限制在 Kendo UI 日期选择器中可选择的天数?

例如 - 仅可选择周一至周五..

<input kendo-date-picker=""    
       ng-model="dateString"
       days="[0,1,2,3,4]"/>

Kendo DatePicker 没有这样的功能:它 has been asked in the Telerik forum 之前,他们的回答是 "the behaviour is not currently supported"。

有一个 UserVoice 项请求创建它。

这是模拟您的意图的自定义解决方法:

$(document).ready(function() {

  var p = $("#datepicker").kendoDatePicker({
    value: new Date(), //setting the value to "today"
    open: function(e) {
      $(".disabledDay").parent().removeClass("k-link");
      $(".disabledDay").parent().removeAttr("href");
      $('.k-weekend a').bind('click', function() {
        return false;
      });
    }
  }).data("kendoDatePicker");
});
.k-weekend {
  background-color: silver;
}
.k-weekend:hover {
  background-color: silver !important;
}
.k-weekend a:hover {
  background-color: silver !important;
}
.k-calendar a:hover {
  background-color: red;
}
<!DOCTYPE html>
<html>

<head>
  <link href="http://cdn.kendostatic.com/2013.3.1119/styles/kendo.common.min.css" rel="stylesheet" type="text/css" />
  <link href="http://cdn.kendostatic.com/2013.3.1119/styles/kendo.default.min.css" rel="stylesheet" type="text/css" />
  <script src="http://code.jquery.com/jquery-1.9.1.min.js"></script>
  <script src="http://cdn.kendostatic.com/2013.3.1119/js/kendo.all.min.js"></script>
  <meta charset=utf-8 />
  <title>KendoUI Example</title>
</head>

<body>
  <input id="datepicker" style="width:150px;" />

</body>

</html>

这并不理想,我知道,但由于小部件本身不存在该功能,因此只有通过变通办法我们才能获得这样的行为。有了这个,你就不能 select 周末了,只要在 CSS 上花点时间,你就可以实现你想要的。