我在Kendo网格的单元格中设置了一个“ monthpicker”。选择器工作正常,并且该列显示MMMM yyyy(例如2019年4月)
但是,当我将焦点从单元格移开时,它并没有将单元格设置为脏的,而是恢复为当前的月份和年份。
编辑器模板(称为Month.cshtml)
@model DateTime?
@{string[] formats = { "MMMM yyyy" }; }
@(Html.Kendo().DatePickerFor(m => m)
.Name("monthpicker")
.Start(CalendarView.Year)
.Depth(CalendarView.Year)
.Format("MMMM yyyy")
.DateInput()
.Culture("en-US")
.ParseFormats(formats)
.HtmlAttributes(new { style = "width: 100%", title = "monthpicker" })
)
型号:
[Display(Name = "Month", ResourceType = typeof(Resources.Resources))]
[UIHint("Month")]
public DateTime Month { get; set; }
查看
@(Html.Kendo().Grid<GrindrodDataCapture.Models.MonthlyOceanPlan>()
.Name("grid")
.Columns(columns =>
{
columns.Bound(c => c.Month).Format("{0:MMMM yyyy}");
//etc
})
.ToolBar(toolbar =>
{
toolbar.Create();
toolbar.Save();
})
.Editable(editable => editable.Mode(GridEditMode.InCell))
.Pageable()
.Sortable(sortable =>
{
sortable.SortMode(GridSortMode.SingleColumn);
})
.Filterable()
.DataSource(dataSource => dataSource
.Ajax()
.Events(events => events.Error("error_handler"))
.Sort(p => { p.Add("Month").Descending(); })
.Model(model => model.Id(p => p.ID))
.Read(read => read.Action("MonthlyOceanPlans_Read", "MonthlyOceanPlanGrid"))
.Create(create => create.Action("MonthlyOceanPlans_Create", "MonthlyOceanPlanGrid"))
.Update(update => update.Action("MonthlyOceanPlans_Update", "MonthlyOceanPlanGrid"))
.Destroy(destroy => destroy.Action("MonthlyOceanPlans_Destroy", "MonthlyOceanPlanGrid"))
)
答案 0 :(得分:0)
我收到了Telerik的支持回复,该回复已解决:)
“嗨,埃文,
我注意到日期选择器编辑器的名称与它编辑的字段的名称不匹配。使用名称设置将编辑器绑定到模型的相应字段。当前,活页夹将尝试将编辑器绑定到模型的monthpicker
字段。但是,模型中的实际字段称为Month
。
此外,当使用WidgetFor助手时,您可以省略名称配置,因为名称会自动设置为字段名称。
您能否删除编辑器的名称配置,并让我知道编辑器是否按预期进行绑定?”