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

Updating EndDate when StartDate doesn't work

3 Answers 37 Views
Scheduler
This is a migrated thread and some comments may be shown as answers.
Erminio
Top achievements
Rank 1
Erminio asked on 22 Feb 2018, 03:03 PM

Hi all,

I'm updating EndDate value when StartDate value changes. This seems to work fine, but when I try to save the appointment the old date value appears in the EndDatePicker and I cannot save the appointment.

 

Here is mycode

 

JavaScript

function changeEndDate(sender, e) {
 var endDatePickerID = sender.get_id().replace("StartDate", "EndDate");
 var endDatePicker = $find(endDatePickerID);
 endDatePicker.set_selectedDate(sender.get_selectedDate());
}

 

c#

RadDatePicker startDate = (RadDatePicker)e.Container.FindControl("StartDate");
if (startDate != null){
startDate.ClientEvents.OnDateSelected = "changeEndDate"
}

 

Can 

 

The code is copied from this link https://docs.telerik.com/devtools/aspnet-ajax/controls/scheduler/how-to/change-the-end-date-when-the-start-date-changes

 

Any help on this?
Thanks a lot

3 Answers, 1 is accepted

Sort by
0
Peter Milchev
Telerik team
answered on 27 Feb 2018, 11:56 AM
Hello Erminio,

The return of the old value is unexpected and it might be related to some customizations. 

Please find attached a sample project and a screencast demonstrating the proper behavior of the code suggested in the provided article. 

If that does not help to resolve the issue, please modify the attached project and send it back to us as an attachment in an official support ticket for further investigation.

Regards,
Peter Milchev
Progress Telerik
Try our brand new, jQuery-free Angular components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
0
Simon
Top achievements
Rank 1
answered on 09 Oct 2019, 08:53 AM

I have the same issue, but with MVC/C#/EF6 and I'm using a CustomEditor for the Scheduler.

I've attached an event to the datetimepicker:

@(Html.Kendo().DateTimePickerFor(model => model.Start).Events(e => e.Change("changedatetime")).HtmlAttributes(generateDatePickerAttributes("startDateTime", "start", "value:start,invisible:isAllDay")))

 

And the following script on the View:

<script type="text/javascript">
    function changedatetime() {
        var dateTimePicker = $("#startDateTime").data("kendoDateTimePicker");
        $("#endDateTime").data("kendoDateTimePicker").value(new Date(dateTimePicker.value()));
    }
</script>

When I update the start date the end date changes/matches, but when the Scheduler is reloaded the end date reverts back to the original date?

0
Simon
Top achievements
Rank 1
answered on 09 Oct 2019, 09:10 AM

I found the solution, after updating the end date you need to trigger the change event to force the new date to be written back to the database.

function changedatetime() {
    var dateTimePicker = $("#startDateTime").data("kendoDateTimePicker");
    $("#endDateTime").data("kendoDateTimePicker").value(new Date(dateTimePicker.value()));
    $("#endDateTime").data("kendoDateTimePicker").trigger("change");
}
Tags
Scheduler
Asked by
Erminio
Top achievements
Rank 1
Answers by
Peter Milchev
Telerik team
Simon
Top achievements
Rank 1
Share this question
or