PDA

View Full Version : [OPEN-1354] 3.3.0 -> Ext.list.BooleanColumn broken



Mjollnir26
21 Oct 2010, 2:43 PM
Hi, not much time this time, Original-Code in 3.3.0 is calling the wrong parent constructor and setting the trueText and falseText isn't working either. Don't drink and code folks :-)

Fixed code is below, fixes are in bold:



Ext.list.BooleanColumn = Ext.extend(Ext.list.Column, {
/**
* @cfg {String} trueText
* The string returned by the renderer when the column value is not falsey (defaults to <tt>'true'</tt>).
*/
trueText: 'true',
/**
* @cfg {String} falseText
* The string returned by the renderer when the column value is falsey (but not undefined) (defaults to
* <tt>'false'</tt>).
*/
falseText: 'false',
/**
* @cfg {String} undefinedText
* The string returned by the renderer when the column value is undefined (defaults to <tt>' '</tt>).
*/
undefinedText: ' ',

constructor : function(c) {
Ext.apply(this, c);
c.tpl = c.tpl || new Ext.XTemplate('{' + c.dataIndex + ':this.format}');

var t = this.trueText, f = this.falseText, u = this.undefinedText;
c.tpl.format = function(v){
if(v === undefined){
return u;
}
if(!v || v === 'false'){
return f;
}
return t;
};

Ext.list.BooleanColumn.superclass.constructor.call(this, c);
}
});
Cheers and keep up the great work :-)

kjleng
23 Nov 2010, 3:29 PM
Thanks for the code, based on the other columns I think it might look more like this, so as not to call ext.apply more than once. (it is called again it the superclass)



constructor : function(c) {
c.tpl = c.tpl || new Ext.XTemplate('{' + c.dataIndex + ':this.format}');

var t = c.trueText || this.trueText, f = c.falseText || this.falseText, u = c.undefinedText || this.undefinedText;
c.tpl.format = function(v){
if(v === undefined){
return u;
}
if(!v || v === 'false'){
return f;
}
return t;
};
Ext.list.BooleanColumn.superclass.constructor.call(this, c);
}