我第一次使用Kendo UI,但遇到了一些问题。当我创建具有DateTime属性的类并在Kendo Grid中实现时,DateTime的字段始终显示“字段DateOfLastCheck必须是日期。”。这是我的剑道代码:
@(Html.Kendo().Grid<Models.OvergasClient>()
.Name("grid")
.Columns(columns =>
{
columns.Bound(c => c.Name).Width(200);
columns.Bound(c => c.Address).Width(200);
columns.Bound(c => c.AddressNumber).Width(200);
columns.Bound(c => c.Floor).Width(200);
columns.Bound(c => c.Appartment).Width(200);
columns.Bound(c => c.RegNumber).Width(200);
columns.Bound(c => c.Telephone).Width(200);
columns.Bound(c => c.isChecked).Width(200);
columns.Bound(c => c.DateOfLastCheck).Format("{0:yyyy/mm/dd}").Width(200);
columns.Bound(c => c.EquipmentNumber).Width(200);
columns.Bound(c => c.Type).Width(200);
columns.Bound(c => c.Note).Width(200);
columns.Bound(c => c.Status).Width(200);
columns.Bound(c => c.Inspector).Width(200);
columns.Bound(c => c.Editor).Width(200);
columns.Command(command => { command.Edit().UpdateText("Запази").CancelText("Откажи").Text("Редактирай"); command.Destroy().Text("Изтрий"); }).Width(180);
})
.ToolBar(toolbar => {
toolbar.Create().Text("Създай");
})
.ColumnMenu()
.HtmlAttributes(new { style = "height:450px;" })
.Editable(editable => editable.Mode(GridEditMode.PopUp))
.Pageable(p => p.Refresh(true).PageSizes(true).ButtonCount(5))
.Selectable(selectable =>
{
selectable.Mode(GridSelectionMode.Single);
selectable.Type(GridSelectionType.Row);
})
.Sortable(sortable =>
{
sortable.SortMode(GridSortMode.SingleColumn);
})
.Filterable()
.Scrollable()
.Groupable(m=>m.Messages(c=>c.Empty("Постави името на колоната тук, за да сортираш по тази колона")))
.Events(events => {
events.Cancel("onCancel");
events.Change("onChange");
events.ColumnHide("onColumnHide");
events.Edit("onEdit");
events.SaveChanges("onSaveChanges");
events.Save("onSave");
events.Remove("onRemove");
events.DetailExpand("onDetailExpand");
events.DataBinding("onDataBinding");
events.DataBound("onDataBound");
events.ColumnShow("onColumnShow");
})
.DataSource(dataSource => dataSource
.Ajax()
.Model(model =>
{
model.Id(m => m.Id);
model.Field(m => m.DateOfLastCheck).Editable(true);
})
.Read(read => read.Action("OvergasClients_Read", "OGTechnika"))
.Create(create => create.Action("OvergasClients_Create", "OGTechnika"))
.Update(update => update.Action("OvergasClients_Update", "OGTechnika"))
.Destroy(destroy => destroy.Action("OvergasClients_Destroy", "OGTechnika"))
)
)
最佳答案
根据此处的文档,http://docs.telerik.com/kendo-ui/framework/globalization/dateformatting mm
表示分钟而不是月份。另外,您的DateOfLastCheck
属性是否可以为空?您可能也要检查一下。