Hi,
I am using Kendo MVC DatePicker. I am trying to disable all the dates except few for the user to select. It is working fine on initial view. When I change the month the dates are getting enabled. I not able to catch the change event for month.(when month is changed).Below is the code. Can you please let me know if you have questions.
<div id="email-settings">
<div style="margin-top: 59px; margin-left: 180px">
@(Html.Kendo().DatePicker()
.Name("calendar")
.Value(DateTime.Today)
.Footer(" ")
.Min(DateTime.Today)
.Depth(CalendarView.Month)
.Events(e =>
{
e.Open("Checkthis");
e.Change("Calender_change");
e.Close("Checkthis");
})
.MonthTemplate("# if ($.inArray(+data.date, events) != -1) { #" +
"#= data.value #" +
"# } else { #" +
"<div class='disabled'>#= data.value #</div>" +
"# } #")
)
</div>
</div>
<script>
var today = new Date(),
events = [
+new Date(today.getFullYear(), today.getMonth(), 29),
+new Date(today.getFullYear(), today.getMonth(), 28)
];
function Checkthis(e) {
$(".disabled").parent().removeClass("k-link") //removing this class makes the day unselectable
$(".disabled").parent().removeAttr("href") //this removes the hyperlink styling
}
function Calender_change(e) {
$(".disabled").parent().removeClass("k-link") //removing this class makes the day unselectable
$(".disabled").parent().removeAttr("href") //this removes the hyperlink styling
}
</script>
I am using Kendo MVC DatePicker. I am trying to disable all the dates except few for the user to select. It is working fine on initial view. When I change the month the dates are getting enabled. I not able to catch the change event for month.(when month is changed).Below is the code. Can you please let me know if you have questions.
<div id="email-settings">
<div style="margin-top: 59px; margin-left: 180px">
@(Html.Kendo().DatePicker()
.Name("calendar")
.Value(DateTime.Today)
.Footer(" ")
.Min(DateTime.Today)
.Depth(CalendarView.Month)
.Events(e =>
{
e.Open("Checkthis");
e.Change("Calender_change");
e.Close("Checkthis");
})
.MonthTemplate("# if ($.inArray(+data.date, events) != -1) { #" +
"#= data.value #" +
"# } else { #" +
"<div class='disabled'>#= data.value #</div>" +
"# } #")
)
</div>
</div>
<script>
var today = new Date(),
events = [
+new Date(today.getFullYear(), today.getMonth(), 29),
+new Date(today.getFullYear(), today.getMonth(), 28)
];
function Checkthis(e) {
$(".disabled").parent().removeClass("k-link") //removing this class makes the day unselectable
$(".disabled").parent().removeAttr("href") //this removes the hyperlink styling
}
function Calender_change(e) {
$(".disabled").parent().removeClass("k-link") //removing this class makes the day unselectable
$(".disabled").parent().removeAttr("href") //this removes the hyperlink styling
}
</script>