PDA

View Full Version : renderer scope change?



Foggy
5 Jun 2009, 6:43 AM
I've got some complications with grid render functions.
In ext2 this code was ok:

var getImage = function(value, metadata, record, rowindex, columnindex, store) {
var fileHelper = new Uwd.Datanode.FileInfo(record, this.dn);
return fileHelper.getImage(this.view.getCurrentView());
}.createDelegate(this);

this.fileCm = new Ext.grid.ColumnModel([{
...
renderer: getImage,
...
}
]);


For ext3 i had to change into this:

var getImage = function(value, metadata, record, rowindex, columnindex, store) {
var fileHelper = new Uwd.Datanode.FileInfo(record, this.dn);
return fileHelper.getImage(this.view.getCurrentView());
}

this.fileCm = new Ext.grid.ColumnModel([{
...
renderer: {
fn: getImage,
scope: this
},

...
}
]);

mjlecomte
5 Jun 2009, 6:53 AM
Thanks for your post Foggy. I moved this to it's own thread for time being to give it better attention.

Yes, I vaguely remember when there were some changes meant to enhance the ability to specify a scope for renderers (so they could be made more reusable, etc.).

Could you provide a simple working showcase so I could look into this a bit further. Again, I think the intent was only to enhance not to break any existing code around this. I'd also like to see the code to see if you're availing yourself of all the new capabilities.

9 Jun 2009, 6:00 AM
I don't get it. in your psuedo code, this.getImage does not exist.

Animal
9 Jun 2009, 6:13 AM
http://extjs.com/deploy/ext-3.0-rc2/docs/?class=Ext.grid.Column&member=renderer

Animal
9 Jun 2009, 6:14 AM
MJ, you see the renderer property there?

Does the latest doc generator embed HTML like that?

hendricd
9 Jun 2009, 6:50 AM
I don't get it. in your psuedo code, this.getImage does not exist.

@Jay -- He's calling his private function with a scope (context) of 'this'. That's often done re-use scenarios where it's not desirable to make a method public.

mjlecomte
9 Jun 2009, 6:52 AM
MJ, you see the renderer property there?

Does the latest doc generator embed HTML like that?

Fixed it, thanks.

9 Jun 2009, 6:53 AM
ah, duh. i read this.getImage.