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

Change Editor Date Format of a column at runtime.

1 Answer 60 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Marc Roussel
Top achievements
Rank 2
Marc Roussel asked on 03 May 2013, 03:46 PM
Please is there a solution somewhere to that problem which even a Support ticket has no result !
I have a GridViewDatacolumn which is of type Date and I can change the DataFormatstring at runtime but when I edit the cell it reverts back to en-US.

Whern the user change language to french I change the Date format to "dd-MM-yyyy" and when he selects english, I change it to "MM-dd-yyyy".  It works find for the visual but the editor is always in "MM-dd-yyyy" 

To date after almost 2 days with MANY hours and a Support ticket that leads no where to date, I'm still looking.
Please someone what is the secret little thing I have to do to have the editor in the same format as the cell display info

1 Answer, 1 is accepted

Sort by
0
Vanya Pavlova
Telerik team
answered on 07 May 2013, 10:55 AM
Hello Marc,


We have already replied to your support ticket. For those members of the community, who might be interested in your case I am posting the answer here, as follows:

You may try to handle PreparingCellForEdit/ PreparedCellForEdit events of RadGridView from where you may access the corresponding Editing Element.
Once you get the RadDateTimePicker instance you can set the date format by changing the Culture property, something like the following:

private void clubsGrid_PreparingCellForEdit(object sender, GridViewPreparingCellForEditEventArgs e)
{
        if ((string) e.Column.Header == "Date")
        {
                var rdt = e.EditingElement as RadDateTimePicker;
 
                rdt.Culture = new CultureInfo("en-US")
               {
                     DateTimeFormat = new DateTimeFormatInfo
               {
                     ShortDatePattern = "dd-MMM-yyyy"
                }
        };
 }
}




Greetings,
Vanya Pavlova
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

Tags
GridView
Asked by
Marc Roussel
Top achievements
Rank 2
Answers by
Vanya Pavlova
Telerik team
Share this question
or