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

Set startTime of TimePickerControl in Grid from clientside

2 Answers 71 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Akhil Raj
Top achievements
Rank 1
Akhil Raj asked on 24 Jun 2010, 10:51 AM
hi,
I have a RadGridView. In the edit form template i have 2 RadTimePciker Control. So using add new command i can get the edit template for enter 2 times.

My requirement is when i select one time in first time picker i need to change the startTime of the second time picker to the next interval. SO i can avoid one validation.
For eg:
 If i select 7:30 in the first time pciker and the time interval is 15 minutes the second time picker's start time is 7:45 only

Any possibility to do in the client side. I saw one evet called onclientTimeSelected But not get any set_StartTime or something like that to set a new start date and also how to get the object in the edit form template in clientside

2 Answers, 1 is accepted

Sort by
0
Martin
Telerik team
answered on 29 Jun 2010, 04:31 PM
Hello Akhil Raj,

To get a reference to the second picker from the DateSelected client-side event handler you can use this approach:

<FormTemplate>
    <telerik:RadTimePicker runat="server" ID="RadTimePicker1">
        <ClientEvents OnDateSelected="DateSelected" />
    </telerik:RadTimePicker>
    <br />
    <telerik:RadTimePicker runat="server" ID="RadTimePicker2">
    </telerik:RadTimePicker>
    <telerik:RadScriptBlock ID="RadScriptBlock1" runat="server">
        <script type="text/javascript">
            function DateSelected(sender, args)
            {
                var picker2 = $find('<%# ((GridItem)Container).FindControl("RadTimePicker2").ClientID %>');
            }
        </script>
    </telerik:RadScriptBlock>
</FormTemplate>


However to set the start time of the second picker you should wire the SelectedDateChanged event of the first RadTimePicker:

protected void RadTimePicker1_SelectedDateChanged(object sender, Telerik.Web.UI.Calendar.SelectedDateChangedEventArgs e)
{
    RadTimePicker picker1 = sender as RadTimePicker;
    RadTimePicker picker2 = picker1.NamingContainer.FindControl("MySecondPicker") as RadTimePicker;
    picker2.TimeView.StartTime = picker1.SelectedDate.Value.TimeOfDay;
}

I hope this helps.

Regards,
Martin
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Akhil Raj
Top achievements
Rank 1
answered on 30 Jun 2010, 05:13 AM
k thanks friend. i just used validation instead of this. but your help is really appreacited...
Tags
Grid
Asked by
Akhil Raj
Top achievements
Rank 1
Answers by
Martin
Telerik team
Akhil Raj
Top achievements
Rank 1
Share this question
or