1

I have a kendo DateTimePicker plugin (open source) in which it shows times from 12 AM to 11:30 PM. I was wondering, if on clicking the time button, I could start the list at 7:30, instead of the first item of the list at 12:00 AM? Is there a way I can have an initial value not at the first item of list, when no time has been selected?

My default registration:

$("#control").kendoDateTimePicker({
        format: "MM/dd/yyyy hh:mm tt",
        min: new Date(1900, 1, 1)
    });
Brian Mains
  • 50,520
  • 35
  • 148
  • 257
  • You can use like pickupFromTpkr.value("7.30"); – Sundar Rajan Nov 17 '14 at 16:19
  • That sets the value; is there a way to do it without explicitly setting the value? That's part of the problem i'm referring to. – Brian Mains Nov 17 '14 at 16:20
  • You can use something like this .Name("start") .Value("8:00 AM") .Min("8:00 AM") .Max("6:00 PM") http://demos.telerik.com/aspnet-mvc/timepicker/rangeselection – Sundar Rajan Nov 17 '14 at 16:47
  • @SundarRajan Value("") actually sets the value to 8 AM; I want only the user to set this, as the whole field can be left empty... And I need a default min/max. I also accidently wrote TimePicker earlier; I'm referring to the DateTimePicker. – Brian Mains Nov 17 '14 at 17:25

1 Answers1

1

There is no simple way to do this :/ But you can still do it ugly but working way, here is the code:

$("#datetimepicker").kendoDateTimePicker({
    open: function(e) {
        if (e.view === "time") {
            var list = $("#"+ e.sender.element.attr('id') + "_timeview");
            if(list.attr('fixed-time-labels') != 'true'){
                var elements = list.find('li:lt(15)');
                elements.insertAfter(list.find('li:last'));
                list.attr('fixed-time-labels', 'true');
            }
        }
    }
});

and here is demo in telerik dojo.

If you do not like :lt(15) you can take culture from kendo.culture() get time format and get li where text == 7:30 AM in current culture.

Jarosław Kończak
  • 3,387
  • 2
  • 19
  • 36