Skip Navigation LinksHome / Community & Support / Developer Productivity Tools Forums / WinForms > Editors (TextBox, MaskedEdit, SpinEditor, BrowseEditor, ColorBox) > Unable to step up in RadDateTimeEditor

Not answered Unable to step up in RadDateTimeEditor

Feed from this thread
  • Jason avatar

    Posted on Oct 19, 2011 (permalink)

    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 );
                    }
            }
    }

    Reply

  • Peter Peter admin's avatar

    Posted on Oct 24, 2011 (permalink)

    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.

    Attached files

    Reply

  • Jason avatar

    Posted on Oct 27, 2011 (permalink)

    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!

    Reply

  • Peter Peter admin's avatar

    Posted on Oct 31, 2011 (permalink)

    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.

    Reply

Back to Top

Skip Navigation LinksHome / Community & Support / Developer Productivity Tools Forums / WinForms > Editors (TextBox, MaskedEdit, SpinEditor, BrowseEditor, ColorBox) > Unable to step up in RadDateTimeEditor
Related resources for "Unable to step up in RadDateTimeEditor"

[ Features | Demos | Documentation | Knowledge Base | Telerik TV | Code Library | Step-by-step Tutorial | Blogs | Self-Paced Trainer ]