PDA

View Full Version : Method signature of column renderers



vaishalishah
10 Feb 2010, 6:38 AM
Hi,
I am new to extjs and needed to know if the column renderer functions have any signature pattern. i was not able to find any relevant solution by going through the api doc.
eg
for one column its:

{
header:'cost',
dataIndex:'cost',
renderer: function(v,params,record){
return Ext.util.Format.usMoney(record.data.estimate+record.data.rate);
}
}


and for the other its

{
header:'estimate',
dataIndex:'estimate',
renderer: function(v){
return v + 'hours'
},
editor: new Ext.form.NumberField({
allowBlank:false,
allowNegative:false
})
}

carol.ext
10 Feb 2010, 7:02 AM
Looking at the ColumnModel API I read this:


See Ext.grid.Column (http://www.extjs.com/deploy/dev/docs/?class=Ext.grid.Column)for additional configuration options for each column.

Under the Column config options, see renderer and it shows an example with params. The example lists params. It also points to setRenderer to see param definition and that looks like this:


The render function is called with the following parameters:

* value : Object

The data value for the cell.
* metadata : Object

An object in which you may set the following attributes:
o css : String

A CSS class name to add to the cell's TD element.
o attr : String

An HTML attribute definition string to apply to the data container element within the table cell (e.g. 'style="color:red;"').

* record : Ext.data.record

The Ext.data.Record from which the data was extracted.
* rowIndex : Number

Row index
* colIndex : Number

Column index
* store : Ext.data.Store

The Ext.data.Store object from which the Record was extracted.

vaishalishah
12 Feb 2010, 1:32 AM
Thx carol