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

DatePicker in Grid Reverts to Default Value After Focus Change

1 Answer 274 Views
Date/Time Pickers
This is a migrated thread and some comments may be shown as answers.
Matthew
Top achievements
Rank 1
Matthew asked on 16 Oct 2015, 04:05 PM

I am trying to use a datepicker in a grid column that utilizes InCell editing.  The problem I am having is that the datepicker appears to revert back to the specified default value after I remove the focus from the datepicker cell into another cell.  Another interesting thing to note is that I can click back into the datepicker cell that I changed and the datepicker will once again show the correct date that I changed the cell too.  Any ideas what causes this behavior?

Here is the date snippet from my viewmodel:

[DisplayName("Month/Year")]
[DisplayFormat(DataFormatString = "{0:MMMM yyyy}")]
[DataType(DataType.Date)]
[Required]
public DateTime FOBDate { get; set; }

 

Here is my Date.cshtml code:

@model DateTime?
 
@(Html.Kendo().DatePickerFor(m => m)
    .Name("fobpricedate")
    .Format("MMMM yyyy")
    .Start(CalendarView.Year)
    .Depth(CalendarView.Year)
)

 

And here is my view that contains the grid:

@(Html.Kendo().Grid<TestMACPortal.Models.FOBViewModel>()
                .Name("grid")
                .Columns(columns =>
                {
                    columns.Bound(c => c.Category).ClientTemplate("#=Category.CategoryName#"); //.EditorTemplateName("ProductCategory");
                    columns.Bound(c => c.SKU_Name);
                    columns.Bound(c => c.MaterialNumber);
                    columns.Bound(c => c.Company).ClientTemplate("#=Company.CompanyName#");
                    columns.Bound(c => c.FOBDate).EditorTemplateName("Date");
                    columns.Bound(c => c.Price).EditorTemplateName("Price");
                })
                .ToolBar(toolbar =>
                {
                    toolbar.Create();
                    //toolbar.Save();
                })
                .Editable(editable => editable.Mode(GridEditMode.InCell))
                .HtmlAttributes(new { style = "height: 500px;" })
                .Scrollable()
                .Sortable()
                .Groupable()
                .Resizable(resize => resize.Columns(true))
                //.Filterable(ftb => ftb.Mode(GridFilterMode.Row))
                .DataSource(dataSource => dataSource
                    .Ajax()
                    .Batch(true)
                    .ServerOperation(false)
                    .Events(events => events.Error("error_handler"))
                    .Model(model =>
                    {
                        model.Id(c => c.FOBID);
                        model.Field(c => c.FOBID).Editable(false);
                        model.Field(c => c.Category).DefaultValue(ViewData["defaultCategory"] as TestMACPortal.Models.ProductCategoryViewModel);
                        model.Field(c => c.Company).DefaultValue(ViewData["defaultCompany"] as TestMACPortal.Models.CompanyViewModel);
                        model.Field(c => c.FOBDate).DefaultValue(DateTime.Today);
                    })
                    //.Destroy("Editing_Destroy", "FOB")
                    .Read(read =>
                    {
                        read.Action("GetFOBs", "FOB");
                    })
                //.Create("CreateFOB", "FOB")
                //.Update("UpdateFOB", "FOB")
                )
        )

 

 

 

 

1 Answer, 1 is accepted

Sort by
0
Georgi Krustev
Telerik team
answered on 20 Oct 2015, 12:54 PM
Hello Matthew,

I am afraid that it is not very clear why the editing with the custom date format does not work well. It could be related to missing custom validation rule for this format or a missing format to the bound column.
Could you modify the attached demo and demonstrate the issue? This will help us to narrow the problem down much faster.

Regards,
Georgi Krustev
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Tags
Date/Time Pickers
Asked by
Matthew
Top achievements
Rank 1
Answers by
Georgi Krustev
Telerik team
Share this question
or