PDA

View Full Version : Column renderer function



foxmarco
7 Jun 2011, 10:58 PM
In Ext3 there was a method in Column of ColumnModel called renderer where was possible add a function to modify the value of column... in Ext4 ???

Ext3 old code example:




/**
* Boolean renderer
*/
booleanRenderer = function (value, metadata, record) {
if (value == 'S' || value == 'true' || value == true)
out = '<img alt="Active" src="' + pathPortal + '/images/apply.gif"/>';
else
out = '<img alt="Not active" src="' + pathPortal + '/images/cross.png"/>';

return out;
}

montipirlo21
7 Jun 2011, 11:14 PM
It seems like 3.x.
Am I wrong or I don't understand?



Ext.grid.column.Column

renderer( Mixed value, Object metaData, Ext.data.Model record, Number rowIndex, Number colIndex, Ext.data.Store store, Ext.view.View view ) : String
A renderer is an 'interceptor' method which can be used transform data (value, appearance, etc.) before it is rendered. Example:

{
renderer: function(value){
if (value === 1) {
return '1 person';
}
return value + ' people';
}
}
Parameters
value : Mixed
The data value for the current cell
metaData : Object
A collection of metadata about the current cell; can be used or modified by the renderer. Recognized properties are: tdCls, tdAttr, and style.
record : Ext.data.Model
The record for the current row
rowIndex : Number
The index of the current row
colIndex : Number
The index of the current column
store : Ext.data.Store
The data store
view : Ext.view.View
The current view
Returns
String
The HTML to be rendered

foxmarco
7 Jun 2011, 11:40 PM
Yes... correct the main problem is the Doc isn't always complete sometime you need to check the code... and this is no good :)

Thanks a lot