View Full Version : Using itemTpl "variables" in lists. (Specifically Date.parseDate)

17 Aug 2011, 10:01 AM
^^Date.format() - not parseDate

I'm attempting to build a list where the main label value is a date. I would like to format the date to match the comp that I've received. I don't want to overload the result coming back from the database because the volume of results will cause significant delays for the end-user.

The snippet I'm using at present looks like:

itemTpl: '<tpl for="."><div class="r c2">'+
'<div class="c"><strong>{[field_date.format("m/d/Y")]}</strong></div>'+
'<div class="c">{field_value}</div>'+

Which yields the following exception:

"ReferenceError: Can't find variable: field_date"

I have tried to also first build the tpl as an XTemplate which yields similar output. Removing the (requisite) brackets results in the constant string of the entire function being output.

If I simply use {field_date} I get the full string representation of the date value output properly.

Does anyone have experience formatting dates, or otherwise consuming variables within itemTpl in this fashion in a working model? If so could I peek at your code?



17 Aug 2011, 4:04 PM

itemTpl: '<tpl for="."><div class="r c2">'+
'<div class="c"><strong>{[values.field_date.format("m/d/Y")]}</strong></div>'+
'<div class="c">{field_value}</div>'+

17 Aug 2011, 4:07 PM

My children thank you.