I have a form that has a standard datepicker that highlights specific dates. Based on the example in the demo section, this is what the control is set up as:
In the Javascript, I have this:
The above code works; the ajax call returns a collection of strings that are all parsed into date objects and pushed in the the events array.
However, at any given time, the collection of dates can change depending on the users input. However, once the datepicker control is initialized, changing the dates array doesn't refresh the highlighted dates in the control (in effect, once the MonthTemplate is rendered, it never reloads).
Is there a way to dynamically change the highlighted dates client side?
@(Html.Kendo().DatePicker()
.Name(
"datepicker"
)
.Value(DateTime.Today)
.HtmlAttributes(
new
{style =
"width: 100%;"
})
.Footer(
"Today - #=kendo.toString(data, 'd') #"
)
.MonthTemplate(
"# if ($.inArray(+data.date, events) != -1) { #"
+
"<div class='"
+
"# if (data.value > 0) { #"
+
"order"
+
"# } #"
+
"'>#= data.value #</div>"
+
"# } else { #"
+
"#= data.value #"
+
"# } #"
))
In the Javascript, I have this:
var
today =
new
Date(),
events = [];
$.ajax({
url:
"GetOrderDates?shipOrderNbr="
+ $(
"#shiporder"
).val(),
dataType:
"json"
,
success:
function
(result) {
events = []; //clear the array of any preexisting dates that may have been loaded
$.each(result,
function
(index, value) {
events.push(
new
Date(value)); //01/01/2015, etc
});
}
});
The above code works; the ajax call returns a collection of strings that are all parsed into date objects and pushed in the the events array.
However, at any given time, the collection of dates can change depending on the users input. However, once the datepicker control is initialized, changing the dates array doesn't refresh the highlighted dates in the control (in effect, once the MonthTemplate is rendered, it never reloads).
Is there a way to dynamically change the highlighted dates client side?