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

[Solved] Problem with DateTime editor within the grid

1 Answer 17 Views
Grid
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Monika
Top achievements
Rank 1
Monika asked on 23 Sep 2011, 11:22 AM
Hi,

When using the telerik asp mvc grid with DataTime field from the Model
I've encountered a very strange behaviour of the DataTime column:
it cannot show the time between 00:00 and 00:59. When the value
of the DataTime field is within this range it is shown in the grid as 01:00

View:
@(Html.Telerik().Grid<DirectionsDepartureViewModel>()
        .Name("DirectionsDepartureTimeGrid")
        .DataKeys(keys =>
        {
            keys.Add(m => m.Id);
        })
        .DataBinding(dataBinding =>
        {
            dataBinding.Ajax()
                .Select(MVC.DirectionsDepartureTime.List())
                .Update(MVC.DirectionsDepartureTime.Edit());
        })
        .Columns(columns =>
        {
 
            columns.Bound(m => m.Name).ReadOnly(true);           
                columns.Bound(m => m.DepartureTime)
                .EditorTemplateName("Time")
                .Format("{0:HH:mm}");
                      
            columns.Command(commands =>
                {
                    commands.Edit();
                }).Title("Commands");           
        })       
        .Editable(editing => editing.Mode(GridEditMode.InLine))
        .Pageable()
        .Scrollable()
        .Sortable()
        .Groupable(grouping => grouping.Groups(groups =>
        {
            groups.Add(c => c.PrintingHouseName);
        }))
        .Filterable()
        .ClientErrorHandling()
    )



Model:

public class DirectionsDepartureViewModel
{
    [ScaffoldColumn(false)]
    public int Id { get; set; }
 
    [Display(Name = "Direction's name")]
    public string Name { get; set; }
 
    [Display(Name = "Departure")]
    [DataType(DataType.Time)]
    [DisplayFormat(NullDisplayText = "")]
    public DateTime? DepartureTime { get; set; }
 
    public string FormattedTime { get; set; }
}

In action I can see that the value entered was correct, it is sent to the database
and stored but still the grid displays the incorrect value from the range mentioned.

Is that a problem with incorrect format provided in the View or am I missing something obvious?
Thanks in advance for any hints

Best regards,
M

1 Answer, 1 is accepted

Sort by
0
Rosen
Telerik team
answered on 26 Sep 2011, 09:04 AM
Hi Monika,

Unfortunately, I'm unable to recreate the behavior you have described. Therefore, it will be appreciated if you could provide a small sample in which it can be observed locally.

Regards,
Rosen
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the Telerik Extensions for ASP.MET MVC, subscribe to their blog feed now
Tags
Grid
Asked by
Monika
Top achievements
Rank 1
Answers by
Rosen
Telerik team
Share this question
or