How to set default DateTime as empty in Kendo DateTime picker

9.4k views Asked by At

I am using Kendo datetime picker, as per their documentation I have set the date time as mentioned below, but by default this piece of code is setting current date and time. But I am looking for something like date time picker should be empty and user needs to be select the date and time. When I tried to remove the new Date() initialization, I was not getting date time picker at all it was just a textbox. Please anybody help in solving this issue.

$("#datetimepicker").kendoDateTimePicker({
value:new Date()
});
2

There are 2 answers

0
Milind Anantwar On BEST ANSWER

set defaultOption to empty or null,

 defaultOption: null

Working Demo

0
sonyisda1 On

In case this helps someone else I was wanting to set the datetime empty in the Kendo UI Scheduler edit template's datetimepicker.

I first add a handler for the edit event .Events(e => e.Edit("onEdit")) and in the function I am setting the model's start and end values which the dropdown is bound to. I specifically check if the scheduler event is new with no recurrence ID to ensure the date/time is only cleared for new events but the value kept for editing existing events:

<script type="text/javascript">
   function onEdit(e) {
      var event = e.event;   
      if (event.isNew() && (event.recurrenceId == null)) {
         // default start/end times to empty
         event.set("start", "");
         event.set("end", "");
      }
   }
</script>