PDA

View Full Version : possible bug in Ext.grid.TemplateColumn



stratton
16 Sep 2009, 10:18 AM
I believe that there is a bug with the line:



var tpl = typeof Ext.isObject(this.tpl) ? this.tpl : new Ext.XTemplate(this.tpl);


I don't think there should be a typeof before the isObject test. The expression always evalutates to TRUE and won't create a new XTemplate instance.

In all cases Ext.isObject returns Boolean. Even Ext.isObject(null) returns Object. If i provide a template as a string, I expect a new XTemplate to be returned by the expression and tpl should be an XTemplate instance- but it is not.



Ext.grid.TemplateColumn = Ext.extend(Ext.grid.Column, {
/**
* @cfg {String/XTemplate} tpl
* An {@link Ext.XTemplate XTemplate}, or an XTemplate <i>definition string</i> to use to process a
* {@link Ext.data.Record Record}'s {@link Ext.data.Record#data data} to produce a column's rendered value.
*/
constructor: function(cfg){
Ext.grid.TemplateColumn.superclass.constructor.call(this, cfg);
var tpl = typeof Ext.isObject(this.tpl) ? this.tpl : new Ext.XTemplate(this.tpl);
this.renderer = function(value, p, r){
return tpl.apply(r.data);
};
this.tpl = tpl;
}
});

Animal
16 Sep 2009, 11:55 AM
You're a Premium member. You should be up to date with the latest code which does not contain that bug!