Hi,
nullable datetime columns ( DateTime ? ) are displayed as textbox in the grid. When I change the column to normal DateTime it displays as a datepicker. Is this expected behaviour? How can I display nullable datetimes as datepicker?
Thanks in advance
Best regards
Markus
nullable datetime columns ( DateTime ? ) are displayed as textbox in the grid. When I change the column to normal DateTime it displays as a datepicker. Is this expected behaviour? How can I display nullable datetimes as datepicker?
Thanks in advance
Best regards
Markus
3 Answers, 1 is accepted
0
Hi Markus,
Currently the GridViewDateTimeColumn does not support nullable types. We plan to add this functionality in one of our upcoming releases.
You could use the CellFormatting event to customize the cell value when it is null. Here is a sample:
I hope this helps. Should you have any further questions, please do not hesitate to ask.
Greetings,
Jack
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
Currently the GridViewDateTimeColumn does not support nullable types. We plan to add this functionality in one of our upcoming releases.
You could use the CellFormatting event to customize the cell value when it is null. Here is a sample:
void radGridView1_CellFormatting(object sender, CellFormattingEventArgs e) |
{ |
if (e.CellElement is GridDateTimeCellElement) |
{ |
GridDateTimeCellElement cell = (GridDateTimeCellElement)e.CellElement; |
if (cell.Value == null || cell.Value == System.DBNull.Value) |
{ |
cell.Text = "null"; |
} |
} |
} |
I hope this helps. Should you have any further questions, please do not hesitate to ask.
Greetings,
Jack
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0

Markus
Top achievements
Rank 1
answered on 26 Feb 2009, 11:02 AM
Hi Jack,
thanks for your answer. The CellFormatting event will work if the db-column is allready null, but what if the user wants to enter the null value? The datepicker seems to have no option to set the date to null.
Because we are using OpenAccess Express there is furthermore a problem with the forward-mapping. If we map the DateTime? (nullable) the db table is created as nullable whereas the "normal" DateTime is mapped with the not null constraint.
Best Regards
Markus
thanks for your answer. The CellFormatting event will work if the db-column is allready null, but what if the user wants to enter the null value? The datepicker seems to have no option to set the date to null.
Because we are using OpenAccess Express there is furthermore a problem with the forward-mapping. If we map the DateTime? (nullable) the db table is created as nullable whereas the "normal" DateTime is mapped with the not null constraint.
Best Regards
Markus
0
Hello Markus,
An option is to customize the context menu for the date time cells. You should handle the ContextMenuOpening event in this case.
Consider the following code snippet:
I hope this helps. If you need further assistance, please write me.
Kind regards,
Jack
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
An option is to customize the context menu for the date time cells. You should handle the ContextMenuOpening event in this case.
Consider the following code snippet:
void radGridView1_ContextMenuOpening(object sender, ContextMenuOpeningEventArgs e) |
{ |
if (e.ContextMenuProvider is GridDateTimeCellElement) |
{ |
RadMenuItem item = new RadMenuItem("Clear date", e.ContextMenuProvider); |
item.Click += new EventHandler(item_Click); |
e.ContextMenu.Items.Add(item); |
} |
} |
void item_Click(object sender, EventArgs e) |
{ |
RadMenuItem menuItem = (RadMenuItem)sender;; |
GridDateTimeCellElement cell = (GridDateTimeCellElement)menuItem.Tag; |
cell.Value = null; |
this.radGridView1.GridElement.Update(GridUINotifyAction.StateChanged); |
} |
I hope this helps. If you need further assistance, please write me.
Kind regards,
Jack
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.