When grid enters edit mode DateTime picker clears value

为君一笑 提交于 2019-12-12 13:17:14

问题


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

回答1:


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


来源:https://stackoverflow.com/questions/10175510/when-grid-enters-edit-mode-datetime-picker-clears-value

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!