Unable to step up in RadDateTimeEditor

4 posts, 0 answers
  1. Jason
    Jason avatar
    24 posts
    Member since:
    Apr 2011

    Posted 19 Oct 2011 Link to this post

    I have a RadGrid performing some timesheet functionality with two columns StartTime and StopTime which are both GridViewDateTimeColumn. A person gets a StartTime when they clock in and a StopTime when they clock out. When the RadDateTimeEditor is initialized, I'm setting it to ShowUpDown and a custom time format since it displays time only. I'm also setting restrictions that the minValue of the StopTime equals the current value of the StartTime (since you can't clock out before you clock in). You can see the attached code for specifics. The problem is situations can occur where there is no valid StopTime. For example, if someone has a StartTime of 11:15 AM and then tries to set the StopTime, the editor will set the NullValue and MinValue of the StopTime to 11:15 AM. The step arrows for up and down show up, but clicking them does nothing since the value for both is invalid. Clicking down makes the time 10:15 AM, which is invalid and clicking up makes the time 12:15 AM which is also invalid. The numbers themselves never actually show up, but this what I assume is happening. I'm not sure what to do to fix this situation. Basically, the stepper will never work if its current value is null and the MinValue is set to anything in between 11:00 - 11:59AM. Maybe I'm missing something. Any help is appreciated.

            private void m_rgvTimesheets_CellEditorInitialized( object sender, GridViewCellEventArgs e )
            {
                if( e.ActiveEditor is RadDateTimeEditor )
                {
                    var editor = (RadDateTimeEditor)(e.ActiveEditor);
                    RadDateTimeEditorElement editorElement = (RadDateTimeEditorElement)editor.EditorElement;
                    editorElement.ShowUpDown = true;
                    editorElement.CustomFormat = "h:mm tt";
                    if( e.Column.Name == ColumnTS_StopTime )
                    {
                        var startTime = (DateTime) e.Row.Cells[ColumnTS_StartTime].Value;
                        editor.NullValue = startTime;
                        editor.MinValue = startTime;
                        editor.MaxValue = GetMaxTime( m_rdtpDatePicker.Value );
                    }
            }
    }
  2. Peter
    Admin
    Peter avatar
    1148 posts

    Posted 24 Oct 2011 Link to this post

    Hi Jason,

    Thank you for writing and for the provided code snippet.

    I can confirm the undesired behavior. There are two ways to resolve this: avoid using the Editor's NullValue property or set the initial value on the Arrow Buttons click.

    Please refer to the attached project which demonstrates the second solution.

    I hope this helps.

    All the best,
    Peter
    the Telerik team

    Q2’11 SP1 of RadControls for WinForms is available for download (see what's new); also available is the Q3'11 Roadmap for Telerik Windows Forms controls.

  3. UI for WinForms is Visual Studio 2017 Ready
  4. Jason
    Jason avatar
    24 posts
    Member since:
    Apr 2011

    Posted 27 Oct 2011 Link to this post

    Hi Peter,

    Thanks for your reply. Not setting the null value property didn't work for me, but your second solution (handling the arrow button) worked great. Thanks!
  5. Peter
    Admin
    Peter avatar
    1148 posts

    Posted 31 Oct 2011 Link to this post

    Hi Jason,

    Thank you for writing back.

    On my side if I remove the editor.NullValue line, then there is valid stop time and I can modify the value with Up/Down arrows.

    var startTime = (DateTime)e.Row.Cells["StartTime"].Value;
    editor.MinValue = startTime; editor.MaxValue = GetMaxTime(m_rdtpDatePicker.Value);
    //editor.NullValue = startTime;

    Do not hesitate to contact us if you have any further questions. All the best,
    Peter
    the Telerik team

    Q2’11 SP1 of RadControls for WinForms is available for download (see what's new); also available is the Q3'11 Roadmap for Telerik Windows Forms controls.

Back to Top