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

Adding client side code to raddatetimepicker

1 Answer 16 Views
Scheduler
This is a migrated thread and some comments may be shown as answers.
Brett
Top achievements
Rank 1
Brett asked on 19 Sep 2013, 03:26 PM
I am looking for a way to add client side code to RadDateTimePicker.  Here is exactly what I am trying to do:

I have two RadDateTimePickers on a single asp.net .aspx page.  The first RadDateTimePicker is named RadDateTimePicker1 and the second RadDateTimePicker is named RadDateTimePicker2.  The starting time and date of an event is RadDateTimePicker1 and the ending time of the event is RadDateTimePicker2.  I want a user to be able to select a date and time with RadDateTimePicker1 and when the date and time is selected, I would like RadDateTimePicker2 to be automatically updated to be 1 hour then RadDateTimePicker1 every time.  Is this possible with javascript/jquery/client side code?  And in addition, is this recommended?  Thanks!

1 Answer, 1 is accepted

Sort by
0
Hristo Valyavicharski
Telerik team
answered on 24 Sep 2013, 05:13 PM
Hi Brett,

You could handle OnClientTimeSelected event and apply the selected date as add one additional hour:
<telerik:RadDateTimePicker ID="RadDateTimePicker1" runat="server" DateInput-Label="Start Date">
    <TimeView runat="server" OnClientTimeSelected="OnClientTimeSelected">
    </TimeView>
</telerik:RadDateTimePicker>
<telerik:RadDateTimePicker ID="RadDateTimePicker2" runat="server" DateInput-Label="End Date"></telerik:RadDateTimePicker>
Date.prototype.addHours = function (h) {
    this.setHours(this.getHours() + h);
    return this;
}
 
function OnClientTimeSelected(sender, args) {
    var selectedTime = args.get_newTime();
    var rdtp2 = $find('RadDateTimePicker2');
    rdtp2.set_selectedDate(selectedTime.addHours(1));
}


Regards,
Hristo Valyavicharski
Telerik
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to the blog feed now.
Tags
Scheduler
Asked by
Brett
Top achievements
Rank 1
Answers by
Hristo Valyavicharski
Telerik team
Share this question
or