问题
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