-
17 Nov 2009 4:58 AM #1
[SOLVED] DateFormat from WebService in grid
[SOLVED] DateFormat from WebService in grid
Hi there!
I'm trying to display a date from a WebService in a grid. The date comes in the ISO 8601 and looks like this: "2009-11-17T13:45:12.423".
The date is saved as dateTime in the SQL-Database and will be transformed in the webservice to the iso-format. Now my problem is that no data is displayed in my Adobe Air application! When I use the type 'string' for the date it is shown but with the ugly ISO-formatCode:var ds = new Ext.data.Store({ proxy: new Ext.data.MemoryProxy(data), reader: new Ext.data.ArrayReader({id: 0}, [ {name: 'id', type:'int'}, ... {name: 'date', type: 'date', dateFormat: 'Y-m-dTH:i:s.u'}, ... {name: 'status', type:'string'} ]) }); var colModel = new Ext.grid.ColumnModel([ ... {header: "Date", width: 80, sortable: true, dataIndex: 'date'}, ... {header: "Status", width: 80, sortable: true, dataIndex: 'status'} ]);
I also tried to change the dateFormat to: dateFormat: 'Y-m-d\\TH:i
.u' and dateFormat: 'c' with no results.
Anyone knows what went wrong?
-
25 Nov 2009 1:44 AM #2
Does nobody got an answer or an idea? Thought this ISO norm is pretty much used?!
-
26 Nov 2009 2:36 AM #3Sencha - Community Support Team
- Join Date
- Mar 2007
- Location
- The Netherlands
- Posts
- 24,251
- Vote Rating
- 40
Date.parseDate uses 'new Function' to create the Date parser function.
Unfortunately, this is only allowed in Adobe AIR during script load, which means you have to declare all your date formats before Ext.onReady, e.g.
(I would recommend using the 'c' date format instead of 'Y-m-d\\TH:i.u')Code:Date.createParser('c'); Ext.onReady(...);
-
27 Nov 2009 7:20 AM #4
Ah - thanks =) I already seen it anywehere but when I tried it it doesn't work. Maybe because I changed something else?
Anyway - now the date will be shown but in a very long format. When trying to change it with:
it does not change the outputCode:{header: "Posteingang", width: 100, /*xtype: 'datecolumn',*/ sortable: true, dataIndex: 'anzahlneuernachrichten', renderer: Ext.util.Format.dateRenderer('d/m/Y')/*format: 'd/m/Y'*/}
Searching for whats going wrong I found a thread where stood that I have to add the following line before the onReady func:
But that gave me an error: "TypeError: Result of expression 'Date.createNewFormat' [undefined] is not a function."Code:Date.createNewFormat('d/m/Y');
When using
there is no error but again there is no change to the dateresultCode:Date.createFormat('d/m/Y');
-
27 Nov 2009 7:37 AM #5Sencha - Community Support Team
- Join Date
- Mar 2007
- Location
- The Netherlands
- Posts
- 24,251
- Vote Rating
- 40
No, it's:
Code:Date.createParser('d/m/Y');
-
27 Nov 2009 8:29 AM #6
That didn't work for me in Adobe Air. But I found the solution here: http://www.extjs.com/forum/showthread.php?t=74310
You must addbefore the onReady funcCode:Date.precompileFormats("d/m/Y");
In Adobe Air it should finally look like:
Code:Date.createParser('c'); Date.precompileFormats("d.m.Y"); Ext.onReady(function(){...}


Reply With Quote