mardi 3 janvier 2017

Set default value to a checkbox in EXT JS (Sencha)

I have a checkbox whose value is bound to a field from database. I want to set a default value 'true'/'checked' if the database contains null value.

The checkbox is :

xtype: 'checkbox',
bind: { value: '{database_variable_name}'},
fieldLabel: 'label_name'

I have tried this formula with no effect (checkbox remains unchecked):

bind: { value: '{checkboxFormula}'}

and

checkboxFormula: {
            get: function (get) {
                var value = get('database_variable_name');
                return (value == null) ? true : value;
            },
            set: function (value) {
                this.set('database_variable_name', value);
            }
}

The whole function works correctly if database does not return null, the checkbox is checked/unchecked accordingly. Any pointers to where I might be going wrong would be appreciated!




Aucun commentaire:

Enregistrer un commentaire