PDA

View Full Version : [FIXED] Boolean Conversion



adamatvips
5 Dec 2011, 8:56 PM
The default behaviour of Sencha Touch for converting to boolean doesn't match that of javascript which caused some issues in our code.

Switching the BOOL function of Ext.data.Type to the code below fixed our issue and seems more intuitive.




BOOL: {
convert: function (v) {
if (this.useNull && (v === undefined || v === null || v === '')) {
return null;

return !!v;
},
sortType: st.none,
type: 'bool'
}


Any chance of getting this into Sencha Touch 2 before release?

Cheers,
Adam

mitchellsimoens
6 Dec 2011, 8:33 AM
Thanks for the report.

TommyMaintz
16 Dec 2011, 12:41 PM
I have updated it to be the following (still converting to false if the value is 'false')



convert: function(v) {
if (this.useNull && (v === undefined || v === null || v === '')) {
return null;
}
return (v !== 'false') && !!v;
},


This will be part of the next release of Touch 2.0

adamatvips
16 Apr 2012, 10:13 PM
I don't think this happend, we still have to override using this:

Ext.data.Types.BOOL.convert = function (value) {

if ((value === undefined || value === null || value === '') && this.getAllowNull()) {
return null;
}
return (value !== 'false') && !!value;

}

Jamie Avins
17 Apr 2012, 8:24 AM
I'll reopen the issue so we can look into it again.

TommyMaintz
9 May 2012, 7:30 AM
Hmm, for some reason the patch I had applied never made it into the code base. This has been fixed for the next release.