We have a couple places in our code where we are using a kendo time or datetime picker and the entry field can accept either a properly formatted date or a "relative" code we came up with. example: 0:+1 = this hour, one minute from now. 0:0 is now. You get the idea. To support someone entering an actual value, two-digit numbers are considered literal. This is a problem with these controls because they appear to be auto=formatting 0:0 to 0:00. We have a work-around by adding a + to the front or a T to the front (we pass the result as unix time format). However, it is desired that we don't have to do this. Is there a way to stop the control from doing this?
Note: I picked "timedurationpicker" as the tag because you don't seem to have the correct tag for timepicker available.
Our code:
Note: I picked "timedurationpicker" as the tag because you don't seem to have the correct tag for timepicker available.
Our code:
function parameterEditor(container, options) {
switch (options.model.ObjectFieldTypeID) {
case @((int)ObjectFieldType.Types.Boolean):
boolEditor(container, options);
break;
case @((int)ObjectFieldType.Types.Integer):
numericEditor(container, options, 0);
break;
case @((int)ObjectFieldType.Types.Double):
numericEditor(container, options, 2);
break;
case @((int)ObjectFieldType.Types.DateTime):
dateTimeEditor(container, options, "kendoDateTimePicker", "M/d/yyyy H:mm", "H:mm");
break;
case @((int)ObjectFieldType.Types.Date):
dateTimeEditor(container, options, "kendoDatePicker", "M/d/yyyy");
break;
case @((int)ObjectFieldType.Types.Time):
dateTimeEditor(container, options, "kendoTimePicker", "H:mm");
break;
default:
stringEditor(container, options);
}
}
function dateTimeEditor(container, options, type, format, timeFormat) {
$('<input id=' + options.field + '>')
.appendTo(container)[type]({ /* dynamically choose the type of kendoXXXPicker (code other than "format" is universal) */
value: options.model.DefaultValue,
format: format,
timeFormat: timeFormat,
})
.data(type);
$("#" + options.field).on("change", function () {
options.model.set(options.field, kendo.toString($(this).val(), format) || $(this).val());
});
}