当网格进入编辑模式时,DateTime选择器清除值(When grid enters edit mode DateTime picker clears value)

编程入门 行业动态 更新时间:2024-10-27 08:38:44
网格进入编辑模式时,DateTime选择器清除值(When grid enters edit mode DateTime picker clears value)

我有一个绑定到网格的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() ); }) )

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() ); }) )

最满意答案

我通过设置编辑器模板来解决问题。 默认情况下,它使用DateTime Picker。 幸运的是,我不需要TimePicker部分。

columns.Bound(r => r.date).Format("{0:d}").EditorTemplateName("Date");

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");

更多推荐

Name,date,columns,电脑培训,计算机培训,IT培训"/> <meta name="description

本文发布于:2023-08-07 18:24:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1465496.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:网格   编辑   模式   选择器   DateTime

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!