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

Kendo UI Grid - Popup mode - DateTime null in Create Ajax mode

1 Answer 188 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Manish
Top achievements
Rank 1
Manish asked on 30 Dec 2013, 10:47 PM
I am using VS2013 + ASP.NET MVC4 + Razor + Kendo Grid 2013.1.219

I am using sample from link
(Custom popup to foreign key)

After lot of work and fixes, its finally working except datetime column is not working. Its passing null dates in create. I have tried setting up below:
[DataType(DataType.DateTime)]
or custom template.
columns.Bound(p => p.Begin_dm).Title("Begin Date").Width(250).Format("{0:MM-dd-yyyy H:mm:ss}").EditorTemplateName("DateTime");
columns.Bound(p => p.End_dm).Title("End Date").Width(250).Format("{0:MM-dd-yyyy H:mm:ss}").EditorTemplateName("DateTime");

Here is my modal:
public class ProviderMaintenanceSMS    
    {
        [ScaffoldColumn(false)]
        public int? PMID { get; set; }
        //[ScaffoldColumn(false)]
        [Required]
        [UIHint("GridForeignKey")]
        public int ProviderID { get; set; }
        [Required]
        //[DataType(DataType.DateTime)]
        public DateTime? Begin_dm { get; set; }
        [Required]
        //[DataType(DataType.DateTime)]
        public DateTime? End_dm { get; set; }
        //[ScaffoldColumn(false)]
        //public DateTime Create_dm { get; set; }
    }

View:
@using SystemDashboard;
@using Kendo.Mvc.UI;

@*model IEnumerable<SystemDashboard.ProviderMaintenanceSMS>*@


@(Html.Kendo().Grid<SystemDashboard.ProviderMaintenanceSMS>()
    .Name("grid1")
    .Columns(columns =>
    {
        columns.Bound(p => p.PMID).Hidden();
        columns.ForeignKey(p => p.ProviderID, (List<ProviderLookup>)ViewData["providers"], "ProviderID", "ProviderName").Title("Provider").Width(150);
        columns.Bound(p => p.Begin_dm).Title("Begin Date").Width(250).Format("{0:MM-dd-yyyy H:mm:ss}").EditorTemplateName("DateTime");
        columns.Bound(p => p.End_dm).Title("End Date").Width(250).Format("{0:MM-dd-yyyy H:mm:ss}").EditorTemplateName("DateTime");
        columns.Command(command => { command.Edit(); command.Destroy(); });
    })
    .ToolBar(toolbar => toolbar.Create())
    .Editable(editable => editable.Mode(Kendo.Mvc.UI.GridEditMode.PopUp))
    .DataSource(dataSource => dataSource
        .Ajax()
         .ServerOperation(false)
        .Events(events => events.Error("error_handler"))
            .Model(model =>
            {
                model.Id(p => p.PMID);
                model.Field(p => p.PMID).Editable(false);
                model.Field(p => p.ProviderID).DefaultValue(1);
            })
        .Create(update => update.Action("EditingSMS_Create", "PM"))
                .Read(read => read.Action("EditingSMS_Read", "PM"))
                .Update(update => update.Action("EditingSMS_Update", "PM"))
                .Destroy(update => update.Action("EditingSMS_Destroy", "PM"))
    )
)
Controller Create Method: (dates are always null here)
   [AcceptVerbs(HttpVerbs.Post)]
        public ActionResult EditingSMS_Create([DataSourceRequest] DataSourceRequest request, ProviderMaintenanceSMS pm)
        {
            ProviderMaintenanceBusinessLayer BL = new ProviderMaintenanceBusinessLayer();
            BL.CreateOrUpdatePMSMS(pm);                        
            return Json(new[] { pm }.ToDataSourceResult(request, ModelState));
        }

Thank you in advance. Looking forward to your reply.

Manish

1 Answer, 1 is accepted

Sort by
0
Petur Subev
Telerik team
answered on 01 Jan 2014, 12:29 PM
Hello Manish,

I posted a reply in the other support ticket that you opened on the same subject, for reference I will paste it here too. Feel free to continue our conversation here or in the other support ticket that you opened on the same subject.

--------------------------------------------------------------------------------------------------------------------------------------------

I assume you have changed the server culture but not the client one accordingly, is this the case?
Same covered in the FAQ section in the documentation:
http://docs.kendoui.com/getting-started/using-kendo-with/aspnet-mvc/helpers/grid/troubleshooting#the-grid-fails-to-update-dates-and-numbers-when-the-current-culture-is-not-en-us
If not send a modified version of the sample so we can investigate further.


--------------------------------------------------------------------------------------------------------------------------------------------


Kind Regards,
Petur Subev
Telerik
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Tags
Grid
Asked by
Manish
Top achievements
Rank 1
Answers by
Petur Subev
Telerik team
Share this question
or