我有一个绑定到网格的DateTime字段。当网格进入编辑模式时,会显示日期/时间选择器,但会从中清除该值。这会强制用户重新输入日期/时间。知道为什么在触发编辑模式时清除它的值?
@(Html.Telerik().Grid<ExpenseGridModel>()
.DataBinding(dataBinding => dataBinding.Ajax()
.Select("ExpenseAjaxBinding", "ExpenseEntry")
.Update("ExpenseUpdate", "ExpenseEntry")
)
.Name("ExpensesGrid")
.DataKeys(keys => keys.Add(r => r.id))
.Columns(columns =>
{
columns.ForeignKey(o => o.categoryId, Model.expenseCategories, "Id", "Name");
columns.ForeignKey(o => o.typeId, Model.expenseTypes, "Id", "Name");
columns.Bound(r => r.date);
columns.ForeignKey(o => o.classId, Model.expenseClasses, "Id", "Name");
columns.Bound(r => r.description);
columns.Bound(r => r.amount);
columns.Command(commands =>
commands.Edit()
);
})
)
答案 0 :(得分:1)
我通过设置编辑器模板解决了这个问题。默认情况下,它使用DateTime Picker。幸运的是,我不需要TimePicker部分。
columns.Bound(r => r.date).Format("{0:d}").EditorTemplateName("Date");