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

GridView Calendar Localization

5 Answers 180 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Guillaume Crétot Richert
Top achievements
Rank 1
Guillaume Crétot Richert asked on 18 Feb 2010, 08:37 PM
Hi!

I'm trying to localize the datetimepicker of a Date column in a RadGridView. I was able to easily localize the RadCalendar using the CultureInfo property, but could find no similar property in RadGridView, and no documentation on how to perform the task at hand.

Thank you for your help.

5 Answers, 1 is accepted

Sort by
0
Accepted
Svett
Telerik team
answered on 19 Feb 2010, 08:46 AM
Hello Guillaume Crétot Richert,

You can localize RadDateTimeEditor, when specify the culture of RadDateTimeEditorElement. So you have to create your own editor that derives from RadDateTimeEditor where you can set its culture. Then you can replace the default editor on EditorRequired event.

You can use the following code snippet as a sample that demonstrates how you can set French culture:

public class RadLocalizableDateTimeEditor : RadDateTimeEditor
{
    private CultureInfo culture;
 
    public RadLocalizableDateTimeEditor()
    {
    }
 
    public CultureInfo Culture
    {
        get { return this.culture; }
        set { this.culture = value; }
    }
 
    protected override Telerik.WinControls.RadElement CreateEditorElement()
    {
        RadDateTimeEditorElement editor = base.CreateEditorElement() as RadDateTimeEditorElement;
        editor.Culture = this.culture;
        return editor;
    }
}

public partial class TicketID283118GridForm : Form
{
    public TicketID283118GridForm()
    {
        InitializeComponent();
        this.radGridView.EditorRequired += new EditorRequiredEventHandler(radGridView_EditorRequired);
    }
 
    private void Form_Load(object sender, EventArgs e)
    {
        this.radGridView.DataSource = DataTableDumper.GenerateEmployees(100);
    }
 
    private void radGridView_EditorRequired(object sender, EditorRequiredEventArgs e)
    {
        if(e.EditorType == typeof(RadDateTimeEditor))
        {
            RadLocalizableDateTimeEditor editor = new RadLocalizableDateTimeEditor();
            editor.Culture = CultureInfo.CreateSpecificCulture("fr");
            e.Editor = editor;
        }
    }
}

Let us know if you have other questions.

Regards,
Svett
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
Guillaume Crétot Richert
Top achievements
Rank 1
answered on 19 Feb 2010, 02:46 PM
I didn't need to inherit the RadDateTimeEditor as it already exposed the Culture property. I simply handled the EditorRequired event and it worked like a charm.

I do believe that it should be default behavior that any control use the CurrentUICulture CultureInfo to localize, but that's just an opinion.

Thanks for the help!
0
Nick
Telerik team
answered on 19 Feb 2010, 03:46 PM
Hello Guillaume Crétot Richert,

You are correct, thank you for sharing your solution with the community. I have updated your Telerik points.

Regards,
Nick
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
Andrew Shyliuk
Top achievements
Rank 1
answered on 07 Apr 2010, 11:32 AM
Hello, All

How do I can to localize value that is displaying in filter after changing it (on attached screenshot).
0
Svett
Telerik team
answered on 12 Apr 2010, 12:52 PM
Hi Andrew Shyliuk,

You can use FormatString property of specified GridViewDataColumn to set the desired formatting. You can use the following code snippet as a sample:
this.radGridView.Columns["HireDate"].FormatString = "{0:dd.MM.yyyy HH:mm:ss}";

You can read more about that in this documentation article.

If you have further questions, do not hesitate to write us back.

Kind regards,
Svett
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
Tags
GridView
Asked by
Guillaume Crétot Richert
Top achievements
Rank 1
Answers by
Svett
Telerik team
Guillaume Crétot Richert
Top achievements
Rank 1
Nick
Telerik team
Andrew Shyliuk
Top achievements
Rank 1
Share this question
or