Sep 27, 2012, 8:36 AM
[CLOSED] Store Sync Date Problem
Hi,
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:
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?
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">
<Proxy>
<ext:AjaxProxy Url='<%# Url.Action("List") %>' AutoDataBind="true">
<API Sync='<%# Url.Action("Save") %>' AutoDataBind="true" />
<Reader>
<ext:JsonReader IDProperty="ID" Root="data" TotalProperty="total" />
</Reader>
<Writer>
<ext:JsonWriter Encode="true" Root="data" />
</Writer>
</ext:AjaxProxy>
</Proxy>
<Model>
<ext:Model runat="server" IDProperty="ID">
<Fields>
<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" />
</Fields>
</ext:Model>
</Model>
</ext:Store>
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.
Where I have to configure the store or model to send dates in iso format or configure deserialize to read utc dates?
Last edited by Daniil; Sep 27, 2012 at 1:41 PM.
Reason: [CLOSED]