This is a migrated thread and some comments may be shown as answers.

How Does Start/End Date Get Set?

1 Answer 284 Views
Scheduler
This is a migrated thread and some comments may be shown as answers.
chobo2
Top achievements
Rank 1
Veteran
chobo2 asked on 04 Jun 2020, 05:51 AM

     Hi

I am looking at the scheduler: https://demos.telerik.com/aspnet-core/scheduler/index and I am wondering when you double click in a day box (on the month view) a "event" dialog comes up. 

How does the start/end get populated. I understand if I click June 3rd box it will populate it with that date. I am guessing it is using the "DateTimePicker" but I am not sure how the correlation works.

I am after not having the "all day" even being checked and I would like to set a default time to the picker.

 

 

 

1 Answer, 1 is accepted

Sort by
0
Ivan Danchev
Telerik team
answered on 08 Jun 2020, 05:41 PM

Hi Michael,

When you double click a slot in the month view, the Scheduler populates the editor with an AllDay event automatically. It does this internally and there is no configuration option that allows turning on/off this behavior. It is possible to customize this behavior in the Scheduler's Edit event handler.

1. Attach a handler for the "Edit" event.

2. In the handler access the "start" and "end" pickers and set the new time values, as demonstrated in the example below:

function onEdit(e) {
  var isNew = e.event.isNew();
  var viewName = e.sender.viewName();

  if(isNew && viewName=="month") {
    e.event.set("isAllDay", false);
    var startElement = e.container.find("[name=start][data-role=datetimepicker]");
    var endElement = e.container.find("[name=end][data-role=datetimepicker]");
    var startPicker = $(startElement).data("kendoDateTimePicker");
    var endPicker = $(endElement).data("kendoDateTimePicker");
    var startDate = e.event.start;
    var endDate = e.event.end;
    //create new dates based on the default start and end dates:
    var newStartDate = startDate.setHours(startDate.getHours() + 4);
    var newEndDate = endDate.setHours(endDate.getHours() - 18);
    
    //set the new dates:
    startPicker.value(new Date(newStartDate));
    startPicker.trigger("change");
    endPicker.value(new Date(newEndDate));
    endPicker.trigger("change");
  }
}

I hope this example points you in the right direction with regard to implementing the desired behavior.

Regards,
Ivan Danchev
Progress Telerik

Progress is here for your business, like always. Read more about the measures we are taking to ensure business continuity and help fight the COVID-19 pandemic.
Our thoughts here at Progress are with those affected by the outbreak.
Tags
Scheduler
Asked by
chobo2
Top achievements
Rank 1
Veteran
Answers by
Ivan Danchev
Telerik team
Share this question
or