Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Setting DateTimePicker to show specific time range e.g. working hours only

Tags:

kendo-ui

I am trying to configure my kendoDateTimePicker to show 9am to 6pm only. Is this possible?

like image 247
hawx Avatar asked Jan 24 '13 11:01

hawx


People also ask

How do you only show time in DatePicker?

In the Data type Format dialog box, do one of the following: To format the control to show the date only, select the display style that you want in the Display the date like this list. To format the control to show the time only, select the display style that you want in the Display the time like this list.

Which property must be changed in the DateTimePicker control to only display the time?

To display the time with the DateTimePicker control Set the ShowUpDown property for the DateTimePicker to true .

What is DateTimePicker (); in JS?

The JavaScript DateTime Picker is a lightweight and mobile-friendly control that allows end users to enter or select date and time values from a pop-up calendar and drop-down time list. It provides month, year, and decade views for quick navigation to the desired date.

What is a time picker?

Time pickers allow users to enter a specific time value. They can be used for a wide range of scenarios. Common use cases include: Setting an alarm. Scheduling a meeting.


2 Answers

I know it's has been a while since this question has been asked. but i will add my response for future reference.

kendo DateTimePicker does not support adding a range to the TimePicker. But you can add your own widget that does that.

(function($) {
        var dateTimePicker = kendo.ui.DateTimePicker;

        var MyWidget = dateTimePicker.extend({

            init: function(element, options) {
                dateTimePicker.fn.init.call(this, element, options);
            },
            startTime: function(startTime) {
                var timeViewOptions = this.timeView.options;
                timeViewOptions.min = startTime;
                this.timeView.setOptions(timeViewOptions);
            },
            endTime: function(endTime) {
                var timeViewOptions = this.timeView.options;
                timeViewOptions.max = endTime;
                this.timeView.setOptions(timeViewOptions);
            },
            options: {
                name: "CustomDateTimePicker"
            }
        });

        kendo.ui.plugin(MyWidget);

    })(jQuery);

Then you can call your CustomDateTimePicker like this :

var datePicker = $("#date-picker").kendoCustomDateTimePicker().data("kendoCustomDateTimePicker");
    datePicker.startTime("07:00");
    datePicker.endTime("11:00");

jsfiddle demo.

like image 119
Waelkat Avatar answered Sep 22 '22 15:09

Waelkat


     var startDateReference = $('.startDate').kendoDateTimePicker({
        format: "dd-MM-yy HH:mm:ss",
        value : new Date(),
     }).data("kendoDateTimePicker");

     startDateReference.timeView.options.min = new Date(2000, 0, 1, 7, 30, 0);
     startDateReference.timeView.options.max = new Date(2000, 0, 1, 18, 00, 0);

This is working for me

like image 40
Danny Avatar answered Sep 25 '22 15:09

Danny