【问题标题】:Monthpicker in Kendo UI for MVC works but sets current month when changing focus from grid cellMVC 的 Kendo UI 中的 Monthpicker 有效,但在从网格单元更改焦点时设置当前月份
【发布时间】:2019-04-04 17:30:06
【问题描述】:

我在剑道网格的一个单元格中设置了一个“月份选择器”。选择器工作正常,列显示 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"))
              )

【问题讨论】:

    标签: kendo-grid kendo-asp.net-mvc kendo-datepicker


    【解决方案1】:

    我得到了 Telerik 的支持回复,修复了它:)

    “嗨,埃文,

    我注意到日期选择器编辑器的名称与其编辑的字段名称不匹配。编辑器使用名称设置绑定到模型的相应字段。目前,绑定器将尝试将编辑器绑定到模型的monthpicker 字段。但是,模型中的实际字段称为Month

    此外,当使用 WidgetFor 助手时,您可以省略名称配置,因为名称会自动设置为字段的名称。

    能否请您删除编辑器的名称配置,并让我知道编辑器是否按预期绑定?"

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2012-07-01
      • 1970-01-01
      • 1970-01-01
      • 2014-07-20
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多