I’m trying to set up a Json Store for an ExtJs Calendar.
The store uses a Http Proxy to retrieve it’s data.
The stores fields include startDate and endDate which are objects of type date.
I’m serializing data in my C# code into Json which will be requested by the Http proxy.
I am wondering should I serialize the start and endates as a string or as C# DateTime type.
At the moment I am serialising them as DateTime types.
The Json response looks like this:
{"Data":
"items":[{
"cid":"0",
"end":"\/Date(1275260400000+0100)\/",
"notes":"4:00",
"start":"\/Date(1275260400000+0100)\/",
"title":"Basic""}]
The start and end properties look like some sort of date reference.
I have tried serialising the startDate and endDate’s as strings rather than DateTime types.
This returns the following JsonResponse:
{"Data":
"items":[{
"cid":"0",
"end":"03/06/10",
"notes":"4:00",
"start":"04/06/10",
"title":"Basic""}]
However, in both cases when the store has finished loading the endDate and startDate fields are undefined.
What should I do here?
I was thinking maybe i have to format the dates into a certain format expected by extjs?
Below is some sample code:
this.eventStore = new Ext.data.JsonStore({
id: 'eventStore',
root: 'Data.items',
proxy: new Ext.data.HttpProxy({
url: AppRootPath + 'Calendar/GetCalendarData',
method: 'POST'
}),//proxy
fields: Ext.calendar.EventRecord.prototype.fields.getRange()
});
Check the documentation for Ext.data.Field – http://dev.sencha.com/deploy/dev/docs/?class=Ext.data.Field . It has a property named ‘dateFormat’ that allows you to specify the exact date format.