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

DataEditFormatString in GridView

2 Answers 163 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Emmanuel Dugas-Gallant
Top achievements
Rank 1
Emmanuel Dugas-Gallant asked on 06 Jul 2010, 06:40 PM
Hi,

I'm trying to list some information about tasks and when I'm trying to set a date/time entry, I'm only able to edit the date part, not the time part.

I've tried to change the DataEditFormatString to be able to change the time part but without success.

What am I doing wrong?

Here is a code of one of the GridViewDateTimeColumn.

            gridViewDateTimeColumn1.DataEditFormatString = "{0:D}"
            gridViewDateTimeColumn1.DataType = typeof(System.DateTime); 
            gridViewDateTimeColumn1.FieldAlias = "DateBegin"
            gridViewDateTimeColumn1.FieldName = "DateBegin"
            gridViewDateTimeColumn1.HeaderText = "DateBegin"
            gridViewDateTimeColumn1.IsAutoGenerated = true
            gridViewDateTimeColumn1.UniqueName = "DateBegin"
            gridViewDateTimeColumn1.Width = 140; 

Thanks,

2 Answers, 1 is accepted

Sort by
0
Emmanuel Dugas-Gallant
Top achievements
Rank 1
answered on 07 Jul 2010, 06:34 PM
Is there anybody there that can help me with this issue?

Thanks!
0
Alexander
Telerik team
answered on 08 Jul 2010, 06:26 PM
Hello Emmanuel,

Thank you for your question.

It is a known issue in the current version of RadGridView. We will address it in a next version.

Meantime, you can implement a custom RadDateTimeEditor which defines the format string that you need:

public class CustomRadDateTimeEditor : RadDateTimeEditor
{
    public override void Initialize(object owner, object value)
    {
        base.Initialize(owner, value);
 
        base.CustomFormat = "dd/MM/yyyy HH:mm:ss";
    }
}

Please use the EditorRequired event to change the used editor for the GridViewDateTimeColumn:

private void radGridView1_EditorRequired(object sender, EditorRequiredEventArgs e)
{
    if (e.EditorType == typeof(RadDateTimeEditor))
    {
        e.EditorType = typeof(CustomRadDateTimeEditor);
    }
}

I hope it helps.

Best wishes,
Alexander
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
Emmanuel Dugas-Gallant
Top achievements
Rank 1
Answers by
Emmanuel Dugas-Gallant
Top achievements
Rank 1
Alexander
Telerik team
Share this question
or