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

GridDataTimeColumn and RadDataPicker

1 Answer 71 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Jhon
Top achievements
Rank 1
Jhon asked on 24 Apr 2012, 01:09 PM
Good afternoon, my name is John and I work in Brazil. I'm doing a project and use some components of Telerik, but I doubt that this is a difficult problem.
The problem is that I can not leave my GridDataTimeColumn in an empty field, I mean, is not required the user to select a specific date.
Only I would like the field of my GridDataTimeColumn stay empty if the user selects not the date on RadDataPicker.

The lower image is an example that you reported, I could not understand what the code that makes this event. How you guys managed to leave the column blank DataTimeColumn, if I do not select a specific date?









Thank you for your attention!


1 Answer, 1 is accepted

Sort by
0
Accepted
Jayesh Goyani
Top achievements
Rank 2
answered on 24 Apr 2012, 02:13 PM
Hello Jhon,

<telerik:GridDateTimeColumn PickerType="DateTimePicker" DataField="customdate" UniqueName="DateTimeColumn">
                   </telerik:GridDateTimeColumn>
protected void RadGrid1_ItemCreated(object sender, GridItemEventArgs e)
   {
       if (e.Item is GridEditableItem && e.Item.IsInEditMode)
       {
           GridDateTimeColumnEditor columnEditor =
               ((GridEditableItem)e.Item).EditManager.GetColumnEditor("DateTimeColumn") as GridDateTimeColumnEditor;
 
           TableCell cell = (TableCell)columnEditor.PickerControl.Parent;
 
           RequiredFieldValidator compareValidator = new RequiredFieldValidator();
           compareValidator.ID = "compareValidator";
           compareValidator.ControlToValidate = columnEditor.PickerControl.ID;
 
           compareValidator.ErrorMessage = "please provide date";
 
           cell.Controls.Add(compareValidator);
       }
   }



Thanks,
Jayesh Goyani
Tags
Grid
Asked by
Jhon
Top achievements
Rank 1
Answers by
Jayesh Goyani
Top achievements
Rank 2
Share this question
or