我正在学习一些 Kendo UI 教程,但我的文本框在网格上的外观有问题。我正在关注的演示是http ://demos.kendoui.com/web/grid/editing-inline.html 。
我已经想出了如何在网格中格式化日期并在编辑器中使用日期选择器作为日期。为此,我使用了一个编辑器模板。
我已经为 name 列添加了一个编辑器模板,这样我就可以应用一个 css 类,它看起来更好,但它不能正常工作。当编辑器打开时,文本框中的值是空的(见图)。当然,必须有一种更简单的方法来应用 css 类。
我是否必须为网格中的所有文本框创建编辑器模板?如果是这样,我怎样才能让它在编辑时带来价值?
这是网格的代码:
@(Html.Kendo().Grid<Product>()
.Name("Grid")
.Columns(columns => {
columns.Bound(p => p.Name);
columns.Bound(p => p.UnitPrice).Width(140);
columns.Bound(p => p.Units).Width(140);
columns.Bound(p => p.Discontinued).Width(100);
columns.Bound(p => p.Date).Width(100).Format("{0:d/M/yyyy}");
columns.Command(command => { command.Edit(); command.Destroy(); }).Width(200);
})
.ToolBar(toolbar => toolbar.Create())
.Editable(editable => editable.Mode(GridEditMode.InLine))
.Pageable()
.Sortable()
.Scrollable()
.DataSource(dataSource => dataSource
.Ajax()
.Events(events => events.Error("error_handler"))
.Model(model => model.Id(p => p.Id))
.Create(update => update.Action("EditingInline_Create", "Home"))
.Read(read => read.Action("EditingInline_Read", "Home"))
.Update(update => update.Action("EditingInline_Update", "Grid"))
.Destroy(update => update.Action("EditingInline_Destroy", "Grid"))
)
)
这是名称编辑器模板的代码:
@using Kendo.Mvc.UI
@model KendoUiOne.Models.Product
@Html.TextBoxFor(x=>x.Name, new {@class = "k-input k-textbox"})