PDA

View Full Version : Formatting date in rowexpander xtemplate



emilyberk
18 Aug 2011, 11:30 AM
I Know there are several forum threads about this but none of the solutions work for me.

In my xtemplate for my row expander I have a date field that I want to format


plugins: [{
ptype: 'rowexpander',
rowBodyTpl: this.something.getRowBodyXTemplate()
}],

the function getRowBodyXTemplate returns the xtemplate string which is like this


'<td > <p> discovered {discovered_at}</p> </td>'

it's the discovered_at Date that i need to format.

it's specified in the model as



{ name: 'discovered_at', type: 'date'},

and i tried this but my date came up undefined


{ name: 'discovered_at', type: 'date', dateFormat: 'n-j-Y g:i A'},


help?

stevil
18 Aug 2011, 12:13 PM
Try reverting your model to




{ name: 'discovered_at', type: 'auto' },



, and changing your template string to:




'<td><p> discovered {discovered_at:date("n-j-Y g:i A")}</p></td>'



http://docs.sencha.com/ext-js/4-0/#/api/Ext.util.Format gives other examples of what you can do with format functions in templates.

hope this helps,

stevil

emilyberk
18 Aug 2011, 12:18 PM
thanks so much. It works :)