PDA

View Full Version : PLEASE URGENT GRID RENDER FUNCTION



ajaxvador
9 Oct 2009, 12:23 AM
I want to dynamic retrieve column name.

grid call function :

{header: 'Discritpion', dataIndex: 'field0', renderer: myfunc } ....


function:

function myfunc(value, p , r){

// retrieve dataindex dynamicly
}


thanks for your help

Condor
9 Oct 2009, 12:55 AM
This is a limitation of the renderer function. It doesn't pass a reference to the view, grid and/or columnmodel.

The only way to make this work is if you have a reference to the view, grid and/or columnmodel in a closure, e.g.

var cm = new Ext.grid.ColumnModel([
...
{header: 'Discritpion', dataIndex: 'field0', renderer: function(value, meta, record, rowIndex, colIndex, store){
var dataIndex = cm.getDataIndex(colIndex);
...
}},
...
]);

ajaxvador
9 Oct 2009, 12:59 AM
Many thanks condor

ajaxvador
9 Oct 2009, 1:08 AM
thanks

Condor
9 Oct 2009, 5:12 AM
Is just realized that retrieving the dataIndex isn't a problem:

function myfunc(value, p , r){
var dataIndex = this.name;
...
}

ajaxvador
9 Oct 2009, 6:45 AM
resolved my problem, thanks condor,

but vadataindex = this.name return a undefined value !

Why ?

thanks