Search code examples
jquerykendo-uiglobalizationkendo-schedulerkendo-template

Kendo UI templates formatting


My Kendo Scheduler uses predefined HTML template, where I have this field:

<input type="text" data-type="date" data-role="datetimepicker" data-bind="value:start,visible:isAllDay" name="start" data-validate="true"/>

This field showing some datetime. Problem is that I can't (or actually don't know how to) format displayed datetime according to this article. How i can solve this?


UPD: Yes, I know about data-format, but it doesn't works everywhere. Please see the picture attached — in this example, formatting via date-format works for field, but not works for time selector ( datarole="datetimeselector" ).

time selector don't recognize format


Solution

  • Did you tried setting the format paramenter as a data attribute?

    <input type="text" data-format="g" data-type="date" data-role="datepicker" data-bind="value:start,visible:isAllDay" name="start" data-validate="true"/>
    

    If that doesn't works, you can always intercept you data(I presume it is remote) with schema.parse:

    dataSource: 
    {
        schema: 
        {
            parse: function(data) 
            {
                for (var i = 0; i < data.length; i++) 
                {
                    data[i].start = kendo.toString(start, "g");
                }
    
                return data;
            }
        }
    }
    

    Not the best way but sometimes it is needed.