Reputation: 2686
I summarize the issue like this.
I use a form to edit user information which is loaded from the DB (I get these values through a JSONStore)
I want to enable/disable a combo depending on the loaded value of another combo.
Example: disable combo2 if the loaded value into combo1 = 0
Any ideas? Thanks
Upvotes: 4
Views: 9313
Reputation: 11
working code segment:
enter code here
{xtype: 'fieldset',
items: [{xtype: 'combo',
hiddenName: 'category[line]',
fieldLabel: 'Category',
store: categories,
emptyText: 'Select',
triggerAction: 'all',
mode: 'local',
displayField: 'category_name',
valueField: 'id',
anchor: '50%',
listeners:{
select:{fn:function(thisCombo, value) {
var combo = Ext.getCmp('combo-subcats');
combo.enable();
//combo.clearValue();
/* category is part of the json data inside the subcat. So the first select choose the category - then filter out only that bit and populate the subcat combo. Make sense? */ combo.store.filter('category', values.data['category']);
}}
}
},
{xtype: 'combo',
hiddenName: 'subcats[line]',
disabled: true,
id: 'combo-subcats',
fieldLabel: 'Sub Cat',
store: getSubcatsStore(),
emptyText: 'Select',
triggerAction: 'all',
mode: 'local',
displayField: 'name',
valueField: 'id',
anchor: '50%',
lastQuery: '' //<-- this is what makes it work.
},
Upvotes: 0
Reputation: 62369
A listener like this should do the job:
formEditUser.getForm().on('actioncomplete',function(form,action) {
if(combo1.getValue() == 0) {
combo2.disable();
} else if (combo1.getValue() == 1) {
combo2.enable();
}
})
Upvotes: 2