PDA

View Full Version : can we read columns in renderer



mbb_online
6 May 2009, 12:12 AM
Hi,

Can I use the colF and colG in the renderer section of colE? Please have a look at colE>renderer section.


var rec = Ext.data.Record.create([
{name: 'colC'},
{name: 'colD'},
{name: 'colE'},
{name: 'colF'},
{name: 'colG'}
]);

Ext.apply(this, {
store: newStore,

columns: [
{header: 'C', width: 100, sortable: true, dataIndex: 'colC'},
{header: 'D', width: 100, sortable: true, dataIndex: 'colD'},
{header: 'E', width: 100, sortable: true, dataIndex: 'colE',
renderer: function(data, cell){

/// how can we use colF and colG in this section?
return getProcessedData(data, colF, colG);
}
}
]
});

jay@moduscreate.com
6 May 2009, 2:37 AM
From the docs Ext.grid.Column



renderer : Mixed
(optional) An "interceptor" method which can be used transform data (value, appearance, etc.) before it is rendered...

(optional) An "interceptor" method which can be used transform data (value, appearance, etc.) before it is rendered). This may be specified in either of three ways:

* A renderer function used to return HTML markup for a cell given the cell's data value.
* A string which references a property name of the Ext.util.Format class which provides a renderer function.
* An object specifying both the renderer function, and its execution scope (this reference) eg:

{
fn: this.gridRenderer,
scope: this
}

If not specified, the default renderer uses the raw data value.

For information about the renderer function (passed parameters, etc.), see Ext.grid.ColumnModel.setRenderer. An example of specifying renderer function inline:

var companyColumn = {
header: "Company Name",
dataIndex: "company",
renderer: function(value, metaData, record, rowIndex, colIndex, store) {
// provide the logic depending on business rules

// name of your own choosing to manipulate the cell depending upon

// the data in the underlying Record object.

if (value == 'whatever') {
//metaData.css : String : A CSS class name to add to the TD element of the cell.

//metaData.attr : String : An html attribute definition string to apply to

// the data container element within the table

// cell (e.g. 'style="color:red;"').

metaData.css = 'name-of-css-class-you-will-define';
}
return value;
}
}

Condor
6 May 2009, 2:42 AM
So you would use:

renderer: function(value, metaData, record){
return getProcessedData(value, record.get('colF'), record.get('colG'));
}