View Full Version : Setting the format of the grid column as %

29 May 2013, 7:03 PM
HI All,

I have a grid with multiple column. How can I format data of one of the column to show % symbol. Is there any inbuilt way to do this? I know I can use renderer but I dont want to go that way.

Look at the below code it allows us to specify the format for a column (number, date). Do we have any similar formatting for %?

Ext.create('Ext.grid.Panel', {
title: 'Date Column Demo',
store: Ext.data.StoreManager.lookup('sampleStore'),
columns: [
{text: 'Symbol', dataIndex: 'symbol', flex: 1},
{text: 'Date', dataIndex: 'date', xtype: 'datecolumn', format:'Y-m-d'},
{text: 'Change', dataIndex: 'change', xtype: 'numbercolumn', format:'0.00'},
{text: 'Volume', dataIndex: 'volume', xtype: 'numbercolumn', format:'0,000'},
{text: 'Top Day', dataIndex: 'topday', xtype: 'datecolumn', format:'l'}
height: 200,
width: 450,
renderTo: Ext.getBody()

29 May 2013, 7:05 PM
console.log(Ext.util.Format.number(123.45, '0,000.00%'));

29 May 2013, 7:25 PM
Hi Evant:
Thank you for quick reply. Correct me if I am wrong, but I think for me to use 'Ext.util.Format.number(123.45, '0,000.00%')' , I have to use renedrer config of the grid column. I want wondering if there is an inbuilt format which I can use for formatting.

29 May 2013, 7:38 PM
This is covered in the docs: