I have an ASP.NET Kendo/MVC DateTimePicker:
We have a requirement that when a user selects a day, we set a default time within the day if not already selected. I use this code to achieve this:
BUT when I set the new value, the width of the picker expands to 100% for some reason (see attachments).
I have to add the commented code to fix the issue.
Why would this be happening?
Thanks
Nathan
@(Html.Kendo()
.DateTimePickerFor(m => m.ResponseRequiredBy)
.Events(e =>
{
e.Change(
"ResponseRequiredBy_OnChange"
);
}))
We have a requirement that when a user selects a day, we set a default time within the day if not already selected. I use this code to achieve this:
function
ResponseRequiredBy_OnChange() {
if
(
this
.value().getHours() == 0 &&
this
.value().getMinutes() == 0) {
var
newDate =
new
Date(
this
.value().getFullYear(),
this
.value().getMonth(),
this
.value().getDate(), 16, 0, 0, 0);
$(
"#ResponseRequiredBy"
).kendoDateTimePicker({
value: newDate,
format:
"dd/MM/yyyy h:mm tt"
});
// overcomes bug whereby Kendo expands field to full width
$(
"#ResponseRequiredBy"
).attr(
"style"
,
""
);
$(
".k-widget.k-datetimepicker.k-header.k-input"
).attr(
"style"
,
""
);
}
}
BUT when I set the new value, the width of the picker expands to 100% for some reason (see attachments).
I have to add the commented code to fix the issue.
Why would this be happening?
Thanks
Nathan