Hybrid View
-
8 Dec 2011 5:37 AM #1
date format in template is not working
date format in template is not working
Hi,
I'm trying to format a date inside of a template:
The timestamp field is defined as follows in the model:Code:{timestamp:date("d.m.Y")}
Unfortunatly the date is not shown if i try to use the :date(format) function. Any ideas or is this a bug?Code:{name: 'timestamp', type: 'date', dateFormat: 'c'},
-
8 Dec 2011 3:58 PM #2
The following code works for me:
Some points:Code:Ext.setup({ onReady: function() { //defgine my model with the timestamp field Ext.define('Model', { extend: 'Ext.data.Model', fields: [ {name: 'timestamp', type: 'date', dateFormat: 'c'} ] }); //create a new instance of that model with a fake timestamp model = Ext.create('Model', { timestamp: '2004-02-12T15:19:21+00:00' }); //show it in a new component using tpl + data Ext.Viewport.add({ tpl: 'The timestamp is: {timestamp}', data: model.data }); } });
- Check your server is outputting the correct response.
- Ensure your model has the proper valueSencha Inc.
Robert Dougan - @rdougan
Sencha Touch 2 and Ext JS 4 Core Team Member, SASS/Theming Wizard.
-
8 Dec 2011 4:38 PM #3
Hi,
this is also working for me. Please try to add a date format inside of the template.
Try the following code:
Code:Ext.Viewport.add({ tpl: 'The timestamp is: {timestamp:date("d.m.Y")}', data: model.data });
-
8 Dec 2011 5:44 PM #4
Ah, sorry. I misread your post.
This is a bug. A quick fix is to open sencha-touch-all-debug.js and go to line 15121. You should see a line like this:
Replace it with this:Code:return v.dateFormat(format || Ext.util.Format.defaultDateFormat);
Code:return Ext.Date.format(v, format || Ext.util.Format.defaultDateFormat);
Sencha Inc.
Robert Dougan - @rdougan
Sencha Touch 2 and Ext JS 4 Core Team Member, SASS/Theming Wizard.
-
23 Jan 2012 6:43 PM #5Sencha - Sencha Touch Dev Team
- Join Date
- Mar 2007
- Location
- Redwood City, California
- Posts
- 3,652
- Vote Rating
- 14
Success! Looks like we've fixed this one. According to our records the fix was applied for
TOUCH-1205
in
2.0.


Reply With Quote