This is a migrated thread and some comments may be shown as answers.

[Solved] When grid enters edit mode DateTime picker clears value

4 Answers 180 Views
Grid
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Jason
Top achievements
Rank 1
Jason asked on 13 Apr 2012, 06:39 PM
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()                                          
            );
        })
         )

4 Answers, 1 is accepted

Sort by
0
Shawn
Top achievements
Rank 1
answered on 24 Apr 2012, 07:05 PM
Im having the exact same problem.  Any luck resolving this?
0
Pechka
Top achievements
Rank 1
answered on 25 Apr 2012, 06:22 AM
Hi

You should specify format to the DateTime picker used as an EditorTemplate (the Shared/EditorTemplates folder).


Also with the latest fixes it should work fine.

Here http://www.telerik.com/products/aspnet-mvc/whats-new/release-history/q1-2012-sp1-version-2012-1-419.aspx the needed format is mentioned.
0
Big T
Top achievements
Rank 1
answered on 15 May 2012, 09:45 AM
Hi, To Solve this put this attribute in your model above any date properties:
 [DataType(DataType.Date), Required]
0
Jo
Top achievements
Rank 1
answered on 03 Oct 2012, 09:54 PM
The solution presented here fixed my issue.  This may help somebody out there.
Tags
Grid
Asked by
Jason
Top achievements
Rank 1
Answers by
Shawn
Top achievements
Rank 1
Pechka
Top achievements
Rank 1
Big T
Top achievements
Rank 1
Jo
Top achievements
Rank 1
Share this question
or