Dear Telerik,
I'm trying to let one RadDateTimePicker communicate with another RadDateTimePicker; when I change the date and or time in the first control, I want to calculate the difference between the old and the new value and pass the difference to the other RadDateTimePicker, so I did the following:
In my AppFormView I created two RadDateTimePickers:
And
I wrote the following Javascript code:
In short it retrieves the old and new date for the first combobox, it calculates the difference in days and then I want to retrieve the current date selected in the RadDateTimePicker and add the same difference to it.
Only, I get the following error: endTimePicker.get_selectedDate is not a function, on the "var oldDate"-line.
What am I doing wrong?! When I look here, get_selectedDate is simply documented...
I'm trying to let one RadDateTimePicker communicate with another RadDateTimePicker; when I change the date and or time in the first control, I want to calculate the difference between the old and the new value and pass the difference to the other RadDateTimePicker, so I did the following:
In my AppFormView I created two RadDateTimePickers:
| <telerik:RadDateTimePicker ID="rdtpAppointments_StartTime" SelectedDate='<%# Bind("StartedOn") %>' runat="server"> |
| <DateInput> |
| <ClientEvents OnValueChanged="OnDateSelected" /> |
| </DateInput> |
| </telerik:RadDateTimePicker> |
And
| <telerik:RadDateTimePicker ID="rdtpAppointments_EndTime" runat="server" SelectedDate="<%# Bind('EndedOn') %>" /> |
I wrote the following Javascript code:
| function OnDateSelected(sender, eventArgs) { |
| var endTimePicker = document.getElementById('<%= AppFormView.FindControl("rdtpAppointments_EndTime").ClientID%>'); ; |
| var newValue = new Date(eventArgs.get_newDate()); |
| var oldValue = new Date(eventArgs.get_oldDate()); |
| var difference = Math.round((newValue - oldValue) / 86400000); |
| var oldDate = new Date(endTimePicker.get_selectedDate()) |
| var newDate = oldDate.setDate(oldDate.getDate()+difference); |
| endTimePicker.set_selectedDate() = newDate; |
| } |
In short it retrieves the old and new date for the first combobox, it calculates the difference in days and then I want to retrieve the current date selected in the RadDateTimePicker and add the same difference to it.
Only, I get the following error: endTimePicker.get_selectedDate is not a function, on the "var oldDate"-line.
What am I doing wrong?! When I look here, get_selectedDate is simply documented...