PDA

View Full Version : Dates in jsonstore working in FF but not in IE or Chrome



toas1
24 Nov 2010, 2:11 AM
Hi guys,

I have grid connected to a jsonstore. My jsonstore is consuming data containing dates formated as ISO dates. I am using json serialization from newtonsoft and for datetime formating I am using the "IsoDateTimeConverter". I have set the type of my date fields (in my jsonstore) to type:'date' and in my grid I am using an Xtemplate where I convert my date using the syntax "value:date('j M'). this works fine in Firefox but in IE and Chrome the cells are "blank" in the grid. It seams like that the date string in my json data cant be converted to a javascript date object in IE and Chrome. Any ideas on what to do? should I use another format when serializing my dates?

Condor
24 Nov 2010, 2:36 AM
You are configuring your field with type:'date', but what dateFormat or convert function are you using with this?

toas1
24 Nov 2010, 3:18 AM
hi Condor,

and thanx for fast reply! I have written an an XTemplate that I am using as a renderer for the two date columns I have in my grid. my XTemplate is pretty simple and looks like this: <span>{value:date('j M')}</span>.

Condor
24 Nov 2010, 4:03 AM
Your tpl assumes that the value of the field in the record contains a Date instance, but I assume that your server is sending a string?

You need to configure the field with type:'date' (as you already do), but also with a dateFormat (so the reader knows how to interpret the date string from the server).

toas1
24 Nov 2010, 4:23 AM
ok,

so if I understand there is a "dateFormat" property on my store that I should use? What should the format be like when I am using the IsoDateTimeFormater then?

Condor
24 Nov 2010, 9:09 AM
I have no idea. Can you post an example of your loaded data?

toas1
24 Nov 2010, 11:05 AM
The output when serializing looks like this: "2000-12-15T22:11:03.055Z"

I checked the source code of the newtonsoft IsoDateTimeConverter and this is the default format but it allows me to override this and set any format I like. So, after checking the documentation of the date (http://dev.sencha.com/deploy/ext/docs/output/Date.html) class I decided to go for the format your define in the "DateTime.Patters" called "SortableDateTime".

By the way, whats the difference between "SortableDateTime" and "ISO8601Long" as defined in the documentation? Both are sortable in the grid or am I wrong?

Condor
24 Nov 2010, 12:12 PM
SortableDateTime? ISO8601Long? These are not Ext JS settings. Are you using Ext GWT (in which case you posted in the wrong forum)?

toas1
24 Nov 2010, 9:55 PM
The are defined in your documentation of the date (http://dev.sencha.com/deploy/dev/docs/) class as "standard date/time patterns". They are only predefined format strings and I was just curious about the difference between them.

Condor
24 Nov 2010, 11:43 PM
Ah, yes. These are common date formats (but they are not defined in Ext).

For your date you would have to use:

dateFormat: 'Y-m-d\\TH:i:s.uT'
or simply:

dateFormat: 'c'

toas1
25 Nov 2010, 12:07 AM
thanks for all your help.