Grid datetime bug

4 posts, 0 answers
  1. Ruben
    Ruben avatar
    4 posts
    Member since:
    Jan 2018

    Posted 25 Jan 2018 Link to this post

    Hi, Im trying to build a table that has 2 datetimes on it.

    My problem is just that, on the method UpdateContainer, the instance container has the default date and never get updated .

    Here is my front code:

    @(Html.Kendo().Grid<WebPruebaTelerik1.Models.Container>()
                                .Name("ContainersStorage")
                                .Columns(columns =>
                                {
                                    columns.Bound(p => p.Id).Title("ID").Width(150).Locked(true);
                                    columns.Bound(p => p.Number).Title("Número").Width(150);
                                    columns.Bound(p => p.Source).Title("Origen").Width(150);
                                    columns.Bound(p => p.Type).Title("Tipo").Width(150);
                                    columns.Bound(p => p.Material).Title("Material").Width(150);
                                    columns.Bound(p => p.Gas).Title("Gas").Width(150);
                                    columns.Bound(p => p.ConstructionDate).Title("Fecha de Fabricación").Format("{0: yyyy-MM-dd HH:mm:ss}").Width(250);
                                    columns.Bound(p => p.InspectionDate).Title("Fecha de Inspección").Format("{0: yyyy-MM-dd HH:mm:ss}").Width(250);
                                    columns.Bound(p => p.ACEP).Title("ACEP").Width(150);
                                    columns.Bound(p => p.Tara).Title("Tara").Width(150);
                                    columns.Bound(p => p.MGW).Title("MGW").Width(150);
                                    columns.Bound(p => p.Trust).Title("Confianza").Width(150);
                                    columns.Command(command => { command.Edit(); command.Destroy(); }).Width(150);
                                })
                                .ToolBar(toolbar => toolbar.Create())
                                .Resizable(resizable => resizable.Columns(true))
                                .Scrollable(scrollable => scrollable.Height(540))
                                .Editable(editable => editable.Mode(GridEditMode.InLine))
                                .Pageable()
                                .Sortable()
                                .HtmlAttributes(new { style = "height:550px;" })
                                .Filterable()
                                .Events(events => events.Save("saveContainers"))
                                .DataSource(dataSource => dataSource
                                    .Ajax()
                                    .PageSize(10)
                                    .Read("ListContainer", "Home")
                                    .Model(model => model.Id(p => p.Id))
                                    .Update("UpdateContainer", "Home")
                                    .Create("CreateContainer", "Home")
                                    .Destroy("DeleteContainer", "Home")
                                )
        )

     

    Here is my controller code :

    public class HomeController : Controller
    {
            [HttpPost]
            public ActionResult UpdateContainer([DataSourceRequest] DataSourceRequest request, Container container)
            {
                dao.EditContainer(container); //Here has a breakpoint
                
                return Json(new[] { container }.ToDataSourceResult(request, ModelState));
            }
    }
    public class Container
        {
            public int Id { get; set; }
            public int Number { get; set; }
            public int Source { get; set; }
            public int Type { get; set; }
            public int Material { get; set; }
            public int Gas { get; set; }
            [DataType(DataType.DateTime)]
            public DateTime ConstructionDate { get; set; } = new DateTime(1970, 1, 1);
            [DataType(DataType.DateTime)]
            public DateTime InspectionDate { get; set; } = new DateTime(1970, 1, 1);
            public string ACEP { get; set; } = "";
            public float Tara { get; set; }
            public float MGW { get; set; }
            public int Trust { get; set; }
        }
  2. Ruben
    Ruben avatar
    4 posts
    Member since:
    Jan 2018

    Posted 25 Jan 2018 in reply to Ruben Link to this post

    Ok I saw the BUG, just the format on the edit mode is dd-MM-yyyy HH:mm:ss but when it sends to server it is parsed to MM-dd-yyyy HH:mm:ss



    So, when I put 10-01-2018 00:00:00 it cant be sended but when I put 15-01-2018 00:00:00 it can be sended, cause my dd (Day) is server's MM (Month) but I cant fix it, Its your bug? How can I fix it? .

  3. Viktor Tachev
    Admin
    Viktor Tachev avatar
    2480 posts

    Posted 26 Jan 2018 Link to this post

    Hello Ruben,

    The behavior that you describe if the globalization options are different on the client and the server. It is recommended to specify matching cultures on the server- and client-side as described in the following article.


    Furthermore, if the server and client are in different time zones the browser will apply offset to the dates by default. This can also result in unexpected behavior in some cases. In such scenario it is recommended to make sure that the same time is used on the server and client.



    Regards,
    Viktor Tachev
    Progress Telerik
    Try our brand new, jQuery-free Angular components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
  4. Ruben
    Ruben avatar
    4 posts
    Member since:
    Jan 2018

    Posted 26 Jan 2018 in reply to Viktor Tachev Link to this post

    Ok, ill try.

     

    I suggest you to add that info to the grid or datatime page :S

  5. Ruben
    Ruben avatar
    4 posts
    Member since:
    Jan 2018

    Posted 26 Jan 2018 in reply to Ruben Link to this post

    Special thanks! its working!
Back to Top