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

Wrong json date string when in line editing datetime

4 Answers 165 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Manuel David
Top achievements
Rank 1
Manuel David asked on 21 May 2015, 06:23 PM

Hi, 

 I have a grid in my project and it's giving me problems. In local enviroment when I try to update inline everything works perfect

{"Data":[{"Id":51,"IdEvento":50,"Nombre":"asdfa","Descripcion":"sadfasd","Escuela":"dsdaf","HoraInicio":"\/Date(1432243240000)\/","HoraTermino":"\/Date(1432288800000)\/","Lugar":"dasf","Estatus":true,"Cupo":6,"Inscritos":1}],"Total":1,"AggregateResults":null,"Errors":null}

 As you can see the date is correctly set, but when deployd to a Q/A enviroment

{"Data":[{"Id":21,"IdEvento":32,"Nombre":"taller 1","Descripcion":"prueba","Escuela":"Escuela uno","HoraInicio":"\/Date(-62135575200000)\/","HoraTermino":"\/Date(-62135575200000)\/","Lugar":"Lugar uno","Estatus":true,"Cupo":48,"Inscritos":22}],"Total":1,"AggregateResults":null,"Errors":{"HoraInicio":{"errors":["The value \u002701/01/1900 12:30:00 p. m.\u0027 is not valid for HoraInicio."]},"HoraTermino":{"errors":["The value \u002701/01/1900 02:00:00 p. m.\u0027 is not valid for HoraTermino."]}}}

The same escenario now sets the date wrong.

This is the code from my grid:

 

01.@(Html.Kendo().Grid(Model).Name("Grid").Columns(
02.                            columns =>
03.                            {
04.                                columns.Bound(p => p.IdEvento);
05.                                columns.Bound(p => p.Nombre);
06.                                columns.Bound(p => p.Descripcion);
07.                                columns.Bound(p => p.Escuela);
08.                                columns.Bound(p => p.HoraInicio).Width(30).Format("{0: dd/MM/yyyy hh:mm tt}");
09.                                columns.Bound(p => p.HoraTermino).Width(30).Format("{0: dd/MM/yyyy hh:mm tt}");
10.                                columns.Bound(p => p.Lugar);
11.                                columns.Bound(p => p.Estatus);
12.                                columns.Bound(p => p.Cupo);
13.                                columns.Bound(p => p.Inscritos);
14.                                columns.Command(command => { command.Edit(); command.Destroy(); }).Width(172);
15.                            })
16.                            .ToolBar(toolbar =>
17.                                {
18.                                    toolbar.Create();
19.                                })
20.                            .Editable(editable => editable.Mode(GridEditMode.InLine))
21.                            .Pageable()
22.                            .DataSource(dataSource => dataSource
23.                                        .Ajax()
24.                                        .PageSize(20)
25.                                        .Events(events =>
26.                                        {
27.                                            events.Error("error_handler");
28.                                        })
29.                                        .Model(model =>
30.                                            {
31.                                                model.Id(p => p.Id);
32.                                                model.Field(p => p.IdEvento).Editable(false).DefaultValue(idEvento);
33.                                            })
34.                                        .Create(update => update.Action("EditingInline_Create", "EditarTaller"))
35.                                        .Update(update => update.Action("EditingInline_Update", "EditarTaller"))
36.                                        .Destroy(update => update.Action("EditingInline_Destroy", "EditarTaller"))
37.                            )
38.)

 

Any help will be greatly appreciated, thanks in advanced.

4 Answers, 1 is accepted

Sort by
0
Daniel
Telerik team
answered on 25 May 2015, 12:19 PM
Hello,

The most likely reason for the problem is a different server-side culture. Could you try using the approach demonstrated here to set the client-side culture based on the server side culture or explicitly setting the server-side culture.

Regards,
Daniel
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
0
Manuel David
Top achievements
Rank 1
answered on 25 May 2015, 10:10 PM

Hi, thanks for your answer. My web.config looks like this:

<globalization culture="es-MX" uiCulture="es-MX" />

And this is in the header of the layout:

 

<script src="@Url.Content("~/Scripts/kendo.culture.es-MX.min.js")"></script>          <script>kendo.culture("es-MX");</script>

Yet the problem persists. 

0
Accepted
Daniel
Telerik team
answered on 27 May 2015, 03:21 PM
Hello again,

The culture seems to be correctly set. The other reason I can think of is the difference in the formats in Windows 7 and Windows 8. Could you try using the Culture helper instead of including the culture script:
@Html.Kendo().Culture()
<script>
    kendo.culture("es-MX");
</script>

It generates the formats based on the current(or specified) .NET culture and so the formats should be the same as the ones expected on the server.

Regards,
Daniel
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
0
Manuel David
Top achievements
Rank 1
answered on 27 May 2015, 05:01 PM

Hi Daniel,

 I did just that and it seem to be working now. I'll run a bunch of test but everything seems in order so far.

Thank you very much for your assistance.

Tags
Grid
Asked by
Manuel David
Top achievements
Rank 1
Answers by
Daniel
Telerik team
Manuel David
Top achievements
Rank 1
Share this question
or