View Full Version : [CLOSED] Store Sync Date Problem

Sep 27, 2012, 8:36 AM

I'm trying to use sync api method of store but unfortunately when I deserialize the model in server-side, dates throws and exception because they are not received in ISO format, they are in UTC format.

This is my store:

<ext:Store ID="myStore" runat="server" PageSize="100" ShowWarningOnFailure="false" RemoteSort="false">
<ext:AjaxProxy Url='<%# Url.Action("List") %>' AutoDataBind="true">
<API Sync='<%# Url.Action("Save") %>' AutoDataBind="true" />
<ext:JsonReader IDProperty="ID" Root="data" TotalProperty="total" />
<ext:JsonWriter Encode="true" Root="data" />
<ext:Model runat="server" IDProperty="ID">
<ext:ModelField Name="ID" Type="Int" />
<ext:ModelField Name="Code" Type="String" />
<ext:ModelField Name="Name" Type="String" />
<ext:ModelField Name="StartDate" Type="Date" SortType="AsDate" />
<ext:ModelField Name="EndDate" Type="Date" SortType="AsDate" />
<ext:ModelField Name="Description" Type="String" />
<ext:ModelField Name="State" Type="Int" SortType="AsInt" />

The way I collect data is the following:

var data = Ext.Net.JSON.Deserialize<List<MyModel>>(base.GetParam<string>("data"));

And this is what I receive:

[{"ID":20370,"Code":"379","Name":"Any Person Name","StartDate":"2011-05-07UTC00:00:00","EndDate":"2011-05-08UTC00:00:00","Description":"Extras Festivas","State":0}]

And when it tries to deserialize crashes in JSONDateTimeJsonConverter.cs line number 106 in the method ReadJson:

return DateTime.Parse(reader.Value.ToString(), CultureInfo.InvariantCulture);

the message is

The string was not recognized as a valid DateTime. There is an unknown word starting at index 10.

Seems that it expects "2011-05-07T00:00:00" instead of "2011-05-07UTC00:00:00".

Where I have to configure the store or model to send dates in iso format or configure deserialize to read utc dates?

Sep 27, 2012, 10:37 AM
Hi @softmachine2011,

It has been fixed yesterday. Please update from SVN or try to set

for the date ModelField.

Sep 27, 2012, 1:13 PM
Tested in rev 4377, works!


Sep 27, 2012, 1:40 PM
Thank you for confirming!