Telerik Forums
Kendo UI for jQuery Forum
1 answer
130 views
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:
    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());
        });
    }

Neli
Telerik team
 answered on 26 Jul 2023
Narrow your results
Selected tags
Tags
+? more
Top users last month
Dominik
Top achievements
Rank 1
Giuliano
Top achievements
Rank 1
Dominic
Top achievements
Rank 1
Glendys
Top achievements
Rank 1
Iron
NoobMaster
Top achievements
Rank 2
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Dominik
Top achievements
Rank 1
Giuliano
Top achievements
Rank 1
Dominic
Top achievements
Rank 1
Glendys
Top achievements
Rank 1
Iron
NoobMaster
Top achievements
Rank 2
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?