PDA

View Full Version : Gird row and column in renderer function



v.madhu
15 Jan 2010, 1:03 AM
Hi ,
I wrote a "Generic" renderer function that is used by several GridPanel.
How to determine the row and column number from the renderer function.

Thanks in advance.

Animal
15 Jan 2010, 1:08 AM
http://www.extjs.com/deploy/dev/docs/?class=Ext.tree.TreePanel&member=click?class=Ext.grid.ColumnModel&member=setRenderer

v.madhu
15 Jan 2010, 1:15 AM
Thanks a Million

v.madhu
15 Jan 2010, 1:26 AM
Since i am using this renderer as "generic" to different GridPanels. Is it possible to know which grid panel is calling this renderer function?

Animal
15 Jan 2010, 1:28 AM
Specify its scope to be the grid:

http://www.extjs.com/deploy/dev/docs/?class=Ext.tree.TreePanel&member=click?class=Ext.grid.Column&member=renderer

Animal
15 Jan 2010, 1:30 AM
Meh, can't do that, it has to be created before the grid!

This is an old problem! It needs a fix in Ext!

v.madhu
15 Jan 2010, 1:33 AM
Thanks for the reply

Condor
15 Jan 2010, 2:19 AM
You could update the renderer scope for all columns after the grid is created (but not loaded).

But I would prefer a default scope, e.g.

Ext.override(Ext.grid.GridView, {
getColumnData : function(){
var cs = [], cm = this.cm, colCount = cm.getColumnCount();
for(var i = 0; i < colCount; i++){
var name = cm.getDataIndex(i);
cs[i] = {
name : (!Ext.isDefined(name) ? this.ds.fields.get(i).name : name),
renderer : cm.getRenderer(i),
scope: cm.getRendererScope(i) || this,
id : cm.getColumnId(i),
style : this.getColumnStyle(i)
};
}
return cs;
}
});

Animal
15 Jan 2010, 2:38 AM
+1000

Access to the grid is so often required in the renderer!

v.madhu
15 Jan 2010, 4:34 AM
Thanks Condor