View Full Version : How to format a date in the teplates

13 Sep 2010, 1:56 AM
Hi, in the designer, when edit the templates of panel, how to specify the format of a date value?

This is the code of mine templates:

<label>id: </label>{id_pratica}<br />
<label>Oggetto: </label>{oggetto}<br />
<label>Protocollo n° : </label>{numero_di_protocollo} <label>del: </label>{data_protocollo}<br />

Thank you

13 Sep 2010, 7:41 PM
you can try {data_protocollo:date) (notice the formatting function comes after the variable name, separated by a colon). You can also try this: {[Ext.util.Format.date(values.data_protocollo)]}

13 Sep 2010, 8:28 PM
OK now I have understood! In the templates I must only specify the type of data( es. date), the format string ('d-m-Y') of the date must be set up in the datastore field option!

Ok now I have

datastore field

MyField8 = Ext.extend(Ext.data.Field, {
constructor: function(cfg) {
cfg = cfg || {};
MyField8.superclass.constructor.call(this, Ext.apply({
name: 'data_protocollo',
dateFormat: 'd-m-Y',
type: 'date'
}, cfg));
new MyField8();

and in the templates

<label>id: </label>{id_pratica}<br />
<label>Oggetto: </label>{oggetto}<br />
<label>Protocollo n° : </label>{numero_di_protocollo} <label>del: </label>{data_protocollo:date}<br />

and all work perfectly

Thank you Jarred