当格进入编辑模式选择器日期时间值清零 [英] When grid enters edit mode DateTime picker clears value
本文介绍了当格进入编辑模式选择器日期时间值清零的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我必须绑定到一个网格中的DateTime字段。当电网进入编辑模式的日期/时间选择器显示,但该值是从它清除。这迫使用户重新输入的日期/时间。任何想法,为什么会触发编辑模式时,它的价值将被清除?
@(Html.Telerik()网格和LT。ExpenseGridModel>()
.DataBinding(数据绑定= GT; dataBinding.Ajax()
。选择(ExpenseAjaxBinding,ExpenseEntry)
.Update(ExpenseUpdate,ExpenseEntry)
)
。名称(ExpensesGrid)
.DataKeys(键=> keys.Add(R = GT; r.id))
.Columns(列=>
{
columns.ForeignKey(O => o.categoryId,Model.expenseCategories,ID,姓名);
columns.ForeignKey(O => o.typeId,Model.expenseTypes,ID,姓名);
columns.Bound(R => r.date);
columns.ForeignKey(O => o.classId,Model.expenseClasses,ID,姓名);
columns.Bound(R => r.description);
columns.Bound(R => r.amount);
columns.Command(命令=>
commands.Edit()
);
})
)
解决方案
我通过设置编辑模板固定的问题。默认情况下它是使用日期时间选择器。幸运的是,我并不需要的TimePicker部分。
columns.Bound(R = GT; r.date).Format({0:D})。EditorTemplateName(日期);
I have a DateTime field bound to a grid. When the grid enters edit mode the date/time picker displays, but the value is cleared from it. This forces the user to re enter the date/time. Any idea why it value is cleared when the edit mode is triggered?
@(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()
);
})
)
解决方案
I fixed the issue by setting the editor template. By default it was using the DateTime Picker. Fortunately I didn't need the TimePicker portion.
columns.Bound(r => r.date).Format("{0:d}").EditorTemplateName("Date");
这篇关于当格进入编辑模式选择器日期时间值清零的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文