RadTimePicker in Grid EditForm

7 posts, 0 answers
  1. RBarnes
    RBarnes avatar
    46 posts
    Member since:
    Oct 2012

    Posted 21 Mar 2013 Link to this post

    I've got a RadTimePicker in Grid EditForm, and I need to set the Min/Max and Interval/StartTime/EndTime

    I've tried setting them in the ItemDatabound of the grid when in edit mode, and on PreRender of the control itself, if I step through debugger, I can see the value get's changed.  But when the editform is rendered, I get the default 1 hour interval.

    I'm at a loss as what else to try.

    Thanks in advance.

    Roger

    <telerik:RadTimePicker ID="txtcmps_StartTime" runat="server" Width="175px" TimeView-Columns="4" OnPreRender="txtcmps_StartTime_PreRender" TimeView-Height="300" TimeView-Width="325" DbSelectedDate='<%# Bind("cmps_StartTime") %>'  TimeView-CssClass="TimePicker" FocusedDate="1/1/1900 12:00:00 AM" MinDate="1/1/1900 12:00:00 AM" DateInput-MinDate="1/1/1900 12:00:00 AM" >       </telerik:RadTimePicker>
     
    Code
     Public Sub txtcmps_StartTime_PreRender(sender As Object, e As System.EventArgs)
            'We'll set our start and end times and interval for txtcmps_StartTime
            If Not IsNothing(ViewState("cmp_StartTime")) Then
                Dim txtcmps_StartTime As Telerik.Web.UI.RadTimePicker = CType(sender, Telerik.Web.UI.RadTimePicker)
                txtcmps_StartTime.MinDate = CType(ViewState("cmp_StartTime"), DateTime)
                txtcmps_StartTime.MaxDate = CType(ViewState("cmp_EndTime"), DateTime)
     
                txtcmps_StartTime.TimeView.Interval = New TimeSpan(0, CType(ViewState("cmp_EnrollmentInterval"), Integer), 0)
                txtcmps_StartTime.TimeView.StartTime = New TimeSpan(CType(ViewState("cmp_StartTime"), DateTime).Hour, CType(ViewState("cmp_StartTime"), DateTime).Minute, CType(ViewState("cmp_StartTime"), DateTime).Second)
                txtcmps_StartTime.TimeView.EndTime = New TimeSpan(CType(ViewState("cmp_EndTime"), DateTime).Hour, CType(ViewState("cmp_EndTime"), DateTime).Minute, CType(ViewState("cmp_EndTime"), DateTime).Second)
     
            End If
        End Sub
  2. Martin
    Admin
    Martin avatar
    811 posts

    Posted 26 Mar 2013 Link to this post

    Hello Roger,

    I would suggest that you set the properties of your picker on the RadGrid's ItemCreated event. You will have to check that the item is EditFormItem and is in edit mode, find the picker and set its properties accordingly.

    I hope this helps.

    Kind regards,
    Martin
    the Telerik team
    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 their blog feed now.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. RBarnes
    RBarnes avatar
    46 posts
    Member since:
    Oct 2012

    Posted 26 Mar 2013 Link to this post

    Thanks Martin, that seemed to work as expected.


  5. Martin
    Admin
    Martin avatar
    811 posts

    Posted 27 Mar 2013 Link to this post

    Hello RBarnes,

    I suspect that the problem comes from a check in our source code that instead of "less than" should read "less than or equal to". Indeed your workaround works and even our online demo uses it. However I think this is an issue that our developers need to address. That is why I am logging it as a bug report which status you can follow here.

    All the best,
    Martin
    the Telerik team
    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 their blog feed now.
  6. RBarnes
    RBarnes avatar
    46 posts
    Member since:
    Oct 2012

    Posted 27 Mar 2013 Link to this post

    After additional thought on my situation, the timepicker is actually correct as it is without the workaround, which I removed.

    If my ending time ends at 4:00 and a user selected 4:00 it would put my ending time at 4:20 if I had a 20 minute interval.

    So I actually need it the way it is 3:40 being my last available selectable time + the interval would put the ending of the last scheduled appointment at 4:00.

  7. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 28 Mar 2013 Link to this post

    Hi,

    I tried the same scenario but I am not able to replicate the issue and its working fine at my end. Here is the sample code i tried with setting the end time as 4PM and 20 minutes as time interval. The user can select the time 4PM from the time picker.

    C#:
    protected void RadGrid1_ItemCreated(object sender, GridItemEventArgs e)
    {
        if (e.Item is GridEditableItem && e.Item.IsInEditMode)
        {
            GridEditableItem Item = (GridEditableItem)e.Item;
            RadTimePicker timePicker = (RadTimePicker)Item.FindControl("RadTimePicker1");
            timePicker.TimeView.Interval = new TimeSpan(0, 20, 0);
            timePicker.TimeView.EndTime = new TimeSpan(16,1,0);
        }
    }

    Thanks,
    Princy.
  8. RBarnes
    RBarnes avatar
    46 posts
    Member since:
    Oct 2012

    Posted 28 Mar 2013 Link to this post


    Wouldn't TimeSpan(16,1,0);  be 4:00 be 4:01 not 4:00

    TimeSpan(16,0,0) will yield the results that I've seen.

    If you want your user to be able to select the absolute ending time 4:00 in this case, the enditme should be increased by the interval, however if you want to selected time plus the interval to the end time, you don't need to add the interval.  In my case I don't want them to be able to select the absolute endtime 4:00, I want the selected time plus the inerval to be the same as the endtime. Thus my appointments don't go past the 4:00 endtime.

    It's working as I need it.

    Thanks for everyone's efforts

    Roger
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017