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,