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

DateTime column with TimePicker editor in Grid

2 Answers 179 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Shlomo Pleban
Top achievements
Rank 1
Shlomo Pleban asked on 06 Mar 2013, 08:46 PM
Hi,

I defined a DateTime column with TimePicker editor in a grid.
When I press the clock, the clock editor is opened, the problem is when I leave the cell without closing the editor (pressing the done, in some cases the editor is closed and in some times its still open, even when I am in a different cell (Decimal column for example). I can still change the time in the editor but it's not connect to anything.

This is how I defined the column:
var dateColumnOut = new GridViewDateTimeColumn
         {
             HeaderText = "Date Time Out",
             Name = Data.cJobCardData.JobCardColumns.DateTimeOut,
             FieldName = Data.cJobCardData.JobCardColumns.DateTimeOut,
             Format = DateTimePickerFormat.Long,
             EditorType = GridViewDateTimeEditorType.TimePicker,
             FormatString = "{0: M/d/yyyy h:mm tt}",
             TextAlignment = ContentAlignment.MiddleCenter,
             Width = colWidth
         };

I checked the CurrentCellChange: The event is fired and I can fill the new cell values. Still, the clock editor is opened and I don't know how to close it.

What am I doing wrong ????

2 Answers, 1 is accepted

Sort by
0
Accepted
Peter
Telerik team
answered on 07 Mar 2013, 04:45 PM
Hi Shlomo,

Thank you for writing.

I was able to reproduce the described behavior. 
As a workaround you should close explicitly the RadTimePickerElement popup on CellEndEdit event. Please, refer to the code below:
private void Form1_Load(object sender, EventArgs e)
{
    ....
    this.radGridView1.CellEndEdit += new GridViewCellEventHandler(radGridView1_CellEndEdit);
    this.radGridView1.CellEditorInitialized += new GridViewCellEventHandler(radGridView1_CellEditorInitialized);
}
 
GridTimePickerEditor editor = null;
void radGridView1_CellEditorInitialized(object sender, GridViewCellEventArgs e)
{
    editor = e.ActiveEditor as GridTimePickerEditor;
}
 
void radGridView1_CellEndEdit(object sender, GridViewCellEventArgs e)
{
    if (editor != null)
    {
        RadTimePickerElement element = (RadTimePickerElement)editor.EditorElement;
        element.ClosePopup();
    }
}

I hope this helps. Greetings,
Peter
the Telerik team
WinForms Q1 2013 boasts PivotGrid, PDF Viewer, Chart enhancements and more. Check out all of the latest highlights.
0
Shlomo Pleban
Top achievements
Rank 1
answered on 07 Mar 2013, 10:02 PM
Thanks
Tags
GridView
Asked by
Shlomo Pleban
Top achievements
Rank 1
Answers by
Peter
Telerik team
Shlomo Pleban
Top achievements
Rank 1
Share this question
or