-
28 May 2012 11:21 PM #1
boolean field never set as modified when set with a boolean value
boolean field never set as modified when set with a boolean value
Hi,
i use extjs 4.1 commercial
i noticed something weird with boolean field.
the field is set as modified when its value is set with a string and not a boolean value. quite unexpected.
here is how it is declared:
{ name:'ready', type:'boolean', defaultValue: false, convert: null }
and the behavior i notice.
record.set('ready', true)
record.isModified('ready') => false
record.set('ready', 'true')
record.isModified('ready') => true
is that a bug or my mistake ?
Thanks
-
28 May 2012 11:28 PM #2
It depends, how is the record constructed?
Evan Trimboli
Sencha Developer
Twitter - @evantrimboli
Don't be afraid of the source code!
-
29 May 2012 12:30 AM #3
here is my model declaration:
the ready field is also correctly set as boolean in the flow of data loaded from the server.Code:Ext.define('QeApp.model.Version', { extend: 'Ext.data.Model', fields: [ { name:'id', type:'int' }, { name:'type', type:'string' }, { name:'ready', type:'boolean', defaultValue: false, convert: null } /* Boolean set as modified when set with string value only */ ], associations: [...] });
Thanks again
-
29 May 2012 12:49 AM #4
I can't reproduce it. I ran this against 4.1.0, it logs true for both records:
Code:Ext.define('Foo', { extend: 'Ext.data.Model', fields: [{ name: 'id', type: 'int' }, { name: 'type', type: 'string' }, { name: 'ready', type: 'boolean', defaultValue: false, convert: null }] }); Ext.onReady(function(){ var rec1 = new Foo({ id: 1, type: 'type1', ready: false }); rec1.set('ready', true); console.log(rec1.isModified('ready')); var rec2 = new Foo({ id: 2, type: 'type2', ready: true }); rec2.set('ready', false); console.log(rec2.isModified('ready')); });Evan Trimboli
Sencha Developer
Twitter - @evantrimboli
Don't be afraid of the source code!
-
29 May 2012 2:06 AM #5
ok, you are right, sorry for the post. I should have make this simple test myself. Thanks for the example. It still don't work in my case...i will find it
Wait! Looks like we don't have enough information to add this to bug database. Please follow this template bug format.


Reply With Quote