kenzominang
kenzominang

Reputation: 67

Extjs tpl for number format

I am new to Extjs. How can I formatting number in tpl?

Here is my code:

{
    xtype: 'panel',
    tpl: [
        '<p>Number: {myDataNumber}</p>'
    ]
}

I have been searching Extjs API for tpl. But I didn't find formating number for tpl. Would you please help me?

Upvotes: 3

Views: 3217

Answers (1)

existdissolve
existdissolve

Reputation: 3114

ExtJS tpl allow for easy formatting using methods from the Ext.util.Format class, which can be implemented with the following syntax:

<p>Number: {myDataNumber:number( "0.00" )}</p>

Of course, you can specify whatever format you need for the number formatting.

Also, if none of the built in format functions work, you could always add to Ext.util.Format (it's a singleton) or specify a custom member function (see Ext.XTemplate docs) for the specific template. Either way, you can implement any format you could imagine...just depends on what the best way is based on your requirements.

Upvotes: 4

Related Questions