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

Date pickers on nested DateTime in Grid : It doesn't change displaying date in grid

2 Answers 342 Views
Date/Time Pickers
This is a migrated thread and some comments may be shown as answers.
Leo
Top achievements
Rank 1
Leo asked on 08 Feb 2016, 02:36 PM

Hello,

I have a grid that use the following ViewModel :

 

 

public class TrackRowViewModel
       {
           public long Id { get; set; }
           public string Name { get; set; }
           public string Description { get; set; }
 
           public MilestoneModel ms1 { get; set; }
           public MilestoneModel ms2 { get; set; }
           public MilestoneModel ms3 { get; set; }
 
           public TrackRowViewModel() { }
       }

 

witch use a MilestoneModel : 

 

public class MilestoneModel
    {
        public long Id { get; set; }
        public string Name { get; set; }
        public string Description { get; set; }
        public DateTime Date { get; set; }
    }

 

I would like to display the date properly in the cells . And use datepicker to change it.

So i tried many way to do it, but the most revelant was Client template and EditorTemplate (ms1)

  

@(Html.Kendo().Grid<Volvo.Qarma.MVCWebUIComponent.Models.Views.TrackRowViewModel>()
           .Name("gridproj")
              .DataSource(dataSource => dataSource
               .Ajax()
               .Batch(true)
               .Model(model =>
               {
                   model.Id(o => o.Id);
                   model.Field(o => o.ms1).DefaultValue(
                   ViewData["defaultms"] as MilestoneModel);
                   model.Field(o => o.ms2).DefaultValue(
                   ViewData["defaultms"] as MilestoneModel);
                   model.Field(o => o.ms3).DefaultValue(
                   ViewData["defaultms"] as MilestoneModel);                   
               })
               .Read(r => r.Action("GetProjectsAllTracksObjectFromProject", "Project"))
               .Create(c => c.Action("Editing_Create", "TracksAndMilestones"))
               .Update(u => u.Action("Editing_Update", "TracksAndMilestones"))
               .Destroy(d => d.Action("Editing_Destroy", "TracksAndMilestones"))
               )
 
       .Columns(columns =>
       {
           columns.Bound(o => o.Name);
           columns.Bound(o => o.Description);
 
 
 
           columns.Bound(o => o.ms1).Title("PCI").HtmlAttributes(new { @class = "color-PCI" }).EditorTemplateName("MilestoneDateEditor").ClientTemplate("#= kendo.toString(kendo.parseDate(ms1.Date, 'yyyy-MM-dd HH:mm:ss'), 'MM/dd/yyyy') #");
           columns.Bound(o => o.ms2).Title("FeG").HtmlAttributes(new { @class = "color-Feg" }).EditorTemplateName("MilestoneDateEditor").ClientTemplate("#= kendo.parseDate(ms2.Date, 'yyyy-MM-dd HH:mm:ss') #");
           columns.Bound(o => o.ms3).Title("CSG").HtmlAttributes(new { @class = "color-CSG" }).EditorTemplateName("MilestoneDateEditor").ClientTemplate("#=ms3.Date#");  
       })
               .ToolBar(toolbar =>
               {
                   toolbar.Create();
                   toolbar.Save();
               })
                       .Editable(editable => editable.Mode(GridEditMode.InCell))
                       .Pageable()
                       .Navigatable()
                       .Sortable()
                       .Scrollable()
   )

--The default value of fields ViewData["defaultms"] is an empty MilestoneModel object--

 

and the Editor as :

 

@model MilestoneModel
 
@(Html.Kendo().DatePickerFor(m => m.Date)
.Name("MilestoneDate")
    .Format("MM/dd/yyyy")
        )

 

My Problem is when change the date with the timepicker editor, the date isn't displaying on the grid properly .

Do i miss something ?

 

Thank you in advanced for your help 

Regards,

 

 

 

 

 

 

 

 

2 Answers, 1 is accepted

Sort by
0
Accepted
Georgi Krustev
Telerik team
answered on 10 Feb 2016, 11:45 AM
Hello Leo,

I believe that the problem is related to the Name of the widget. When strongly-typed extension is used, you should avoid setting the name manually: Could you try the widget without setting the name? Is there any difference in the behavior? If no, could you send us a repro demo that demonstrates the issue?

Regards,
Georgi Krustev
Telerik
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 Feedback Portal and vote to affect the priority of the items
0
Leo
Top achievements
Rank 1
answered on 15 Feb 2016, 03:32 PM

Hi Georgi.

It's works fine !

In my case:

 

@model MilestoneModel
   
@(Html.Kendo().DatePickerFor(m => ms.Date)
.Name("ms1.Date")
    .Format("MM/dd/yyyy")
        )

 

With one custom editor by bounded value  (ms1 , ms2 , and ms3).

 

Thanks for your help !

Regards

 

 Léo

 

Tags
Date/Time Pickers
Asked by
Leo
Top achievements
Rank 1
Answers by
Georgi Krustev
Telerik team
Leo
Top achievements
Rank 1
Share this question
or