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

3 posts, 1 answers
  1. Leo
    Leo avatar
    9 posts
    Member since:
    Dec 2015

    Posted 08 Feb Link to this post

    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. Answer
    Georgi Krustev
    Admin
    Georgi Krustev avatar
    3706 posts

    Posted 10 Feb Link to this post

    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
  3. UI for ASP.NET MVC is VS 2017 Ready
  4. Leo
    Leo avatar
    9 posts
    Member since:
    Dec 2015

    Posted 15 Feb in reply to Georgi Krustev Link to this post

    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

     

Back to Top