14 Answers, 1 is accepted
You cannot put a RadDateTimePicker in RadGridView at this moment. The RadDateTimePicker is not a stand alone control - rather, it was developed to be a plug in module for RadCalendar. Once we provide RadDateTimePicker as a separate control with example and documentation, we will include an example of it with RadGridView.
Peter
the Telerik team
Instantly find answers to your questions at the new Telerik Support Center
regards
GridViewMaskBoxColumn maskColumn =
new
GridViewMaskBoxColumn(
"Date"
);
maskColumn.MaskType = MaskType.DateTime;
maskColumn.Mask =
"d"
;
this
.radGridView1.Columns.Add(maskColumn);
Regards,
Jack
the Telerik team
Instantly find answers to your questions at the new Telerik Support Center
Just set the ReadOnly property of the column to true if you want to disable the editor. If you want to hide the popup of the editor, please consider the code snippet below:
void
radGridView1_CellBeginEdit(
object
sender, GridViewCellCancelEventArgs e)
{
RadDateTimeEditor editor =
this
.radGridView1.ActiveEditor
as
RadDateTimeEditor;
if
(editor !=
null
)
{
RadDateTimeEditorElement editorElement = editor.EditorElement
as
RadDateTimeEditorElement;
editorElement.ShowUpDown =
true
;
}
}
As to the second part of your question, the user cannot select a date before first clicking in a RadDateTimeEditor (our date time editor). Please describe your scenario in detail and I will be glad to assist you.
Regards,
Jackthe Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
thk, regards
You can get the current value of a date time picker by using ActiveEditor.Value property and you can save it by calling EndEdit method. In all cases, you need some interaction from the user to save the value. In RadGridView this happens when you click on a different cell or when you navigate with the keyboard (by using Tab, Left, Right keys for example). The editor saves its value also when pressing the Enter key. If you expect different behavior, please describe it in detail and I will be glad to help.
Sincerely yours,
Jackthe Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Hi Jack. I'm having issues with the RadDateTimeEditor in my RadGridView. I'm using the UI for WinForm (v.2017.1.117.40). In my RadGridView, I have standard number editors, text only editors and datetime editors that come standard when data filling my radgridview.
When I start editing my columns, let's say I edit my number column, then I press the TAB key, the value I put in stayed in the column. Same for my text only columns. But when I get to my datetime editor and press TAB (or ENTER), the value disappears. But when I click out, it's saved. I don't have any cell validating event on key press. Can you replicate this problem?
Hi Jack. I'm having issues with the RadDateTimeEditor in my RadGridView. I'm using the UI for WinForm (v.2017.1.117.40). In my RadGridView, I have standard number editors, text only editors and datetime editors that come standard when data filling my radgridview.
When I start editing my columns, let's say I edit my number column, then I press the TAB key, the value I put in stayed in the column. Same for my text only columns. But when I get to my datetime editor and press TAB (or ENTER), the value disappears. But when I click out, it's saved. I don't have any cell validating event on key press. Can you replicate this problem?
[/quote]
I forgot to mention that this behavior only happens in the "add new row" line of the RadGridView.
I cannot reproduce this locally. I have attached a small video that shows how I am testing this. What else I need to do in order to reproduce it?
I am looking forward to your reply.
Regards,
Dimitar
Telerik by Progress
Thanks for the quick reply. I've narrowed the problem down. I want to change the masktype of the RadDateTimeEditor to FreeFormDateTime. And since I did that, the TAB and ENTER buttons don't work anymore inside that cell. Here's the code I'm using.
private
void
FilterableDataGrid_CellEditorInitialized(
object
sender, GridViewCellEventArgs e)
{
var radDateTimeEditor = _filterableDataGrid.ActiveEditor
as
RadDateTimeEditor;
if
(radDateTimeEditor ==
null
)
return
;
var radDateTimeEditorElement = (RadDateTimeEditorElement)radDateTimeEditor.EditorElement;
var radDateTimePickerCalendar = radDateTimeEditorElement.GetCurrentBehavior()
as
RadDateTimePickerCalendar;
if
(radDateTimePickerCalendar ==
null
)
return
;
var radDateTimePickerElement = radDateTimePickerCalendar.DateTimePickerElement;
radDateTimePickerElement.Format = DateTimePickerFormat.Custom;
var radMaskedEditBoxElement = radDateTimePickerCalendar.TextBoxElement;
radMaskedEditBoxElement.EnableNullValueInput =
true
;
radMaskedEditBoxElement.MaskType = MaskType.FreeFormDateTime;
const
string
dateFormat =
"yyyy-MM-dd"
;
if
(e.Column.Name.Contains(
"ValidTo"
))
{
radDateTimePickerElement.CustomFormat = radMaskedEditBoxElement.Mask = $
"{dateFormat} 23:59:59"
;
}
else
if
(e.Column.Name.Contains(
"ValidFrom"
))
{
radDateTimePickerElement.CustomFormat = radMaskedEditBoxElement.Mask = $
"{dateFormat} 00:00:00"
;
}
else
{
radDateTimePickerElement.CustomFormat = radMaskedEditBoxElement.Mask = $
"{dateFormat} HH:mm:ss"
;
}
}
Thank you!
Do I have to implement something similar to this, but catching the TAB and ENTER keys instead?
I was able to reproduce this. It is caused by an issue in our implementation, I have logged the issue in our Feedback Portal. I have added a vote for it on your behalf as well. You can track its progress, subscribe for status changes and add your comment to it here. I have also updated your Telerik Points.
To workaround this you need to create custom editor:
class
Myditor : RadDateTimeEditor
{
public
override
bool
IsModified
{
get
{
return
true
;
}
}
}
You can use the EditorRequired event to replace the default editor:
private
void
RadGridView1_EditorRequired(
object
sender, EditorRequiredEventArgs e)
{
if
(e.EditorType ==
typeof
(RadDateTimeEditor))
{
e.Editor =
new
Myditor();
}
}
Should you have any other questions do not hesitate to ask.
Regards,
Dimitar
Telerik by Progress