【问题标题】:Kendo Grid inline editing with Kendo DataPicker使用 Kendo DatePicker 进行 Kendo Grid 内联编辑
【发布时间】:2016-01-01 23:09:07
【问题描述】:

我正在使用具有三列名称、日期的 Kendo 网格,我在其中一列中有编辑按钮,现在我单击“编辑”按钮,然后相应的行应该处于编辑模式,并且 KendoDataPicker 在“日期”字段中的网格内。如何做到这一点?

@(Html.Kendo().Grid<MyModel.ResultM>()
                                   .Name("ResultsGrid")
                                   .Sortable()
                                   .Events(grid => grid.DataBound("fnShowNoRecordsFoundMsg"))
                                   .AutoBind(true)
                                   .Scrollable(scr => scr.Height("auto"))
                                   .Sortable(sortable => sortable.AllowUnsort(false))
                                   .Columns(columns =>
                                   {
                                       columns.Bound(p => p.Name).Title("Name").Width(27);
                                       columns.Bound(p => p.Date).Title("Date").Width(27).EditorTemplateName((
                                       @Html.Kendo().DatePicker()
                                 .Name("FDPicker")
                                            //.Value()
                                            .HtmlAttributes(new { data_bind = "value:Date" })
                                       .Format("{0:MM/dd/yy}")

                                .ToClientTemplate()).ToHtmlString());
                                       columns.Command(command => { command.Destroy(); command.Edit(); }).Width(24);
                                   })
                                       .Editable(editable => editable.Mode(GridEditMode.InLine).CreateAt(GridInsertRowPosition.Bottom))
                                        .DataSource(Resultdatasource=> Resultdatasource
                                        .Ajax()
                                        .Sort(sort => sort.Add("Date").Descending())
                                        .Model(model => model.Id(p => p.Name))
                                        .ServerOperation(false)
                                        .Read(read => read.Action("Results_Read", "Home").Data("fnGetParamsObject"))
                                        .Update(update => update.Action("EditingInline_Update", "Home"))
                                        .Destroy(update => update.Action("EditingInline_Destroy", "Home"))
                                                )
)

【问题讨论】:

  • 编辑和删除功能适用于此代码。但是我在网格中单击编辑后没有得到剑道选择器。

标签: asp.net-mvc-4 model-view-controller kendo-ui telerik kendo-grid


【解决方案1】:

内联编辑依赖于 EditorTemplates。试试这样的:

columns.Bound(p => p.Date)
        .Format("{0:MM/dd/yyyy}")
        .Width(190)
        .EditorTemplateName("DateTime");

您可能还需要将编辑器模板从您的计算机复制到您的~\Views\Shared\EditTemplates 文件夹。

对我来说,他们在这里:
C:\Program Files (x86)\Telerik\UI for ASP.NET MVC Q2 2015\wrappers\aspnetmvc\EditorTemplates\razor

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-10-30
    • 2017-06-14
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多