PDA

View Full Version : check checkbox to disable/enable triggerfiled



Dannesart
28 Nov 2011, 6:27 AM
Hi I got a checkbox and a triggerfield. So when I check the checkbox the triggerfield should be enable, and default should be disable.

my triggerfield:
{
xtype: 'common.user.triggerfield',
fieldLabel: 'Säljare',
disabled: true,
emptyText: 'Välj säljare',
labelWidth: 120,
itemId: 'selectSalesPerson'

}

my checkbox:
{
xtype: 'checkboxfield',
fieldLabel: 'Skapa säljsamtal',
labelWidth: 120,
itemId: 'createSale'
},

And the code events:


initComponent: function () {
this.callParent(arguments);
this.defineReferences();
this.createSale.on('change', this.onCreateSalesSelected, this);
this.selectSalesPerson.on('validitychange', this.onSelectSalesPerson, this);

},
defineReferences: function() {
this.createSale = this.down('#createSale');
his.selectSalesPerson = this.down('#selectSalesPerson');

},

onCreateSalesSelected: function(model, selected, options) {
this.onSelectSalesPerson().setDisabled(false);

},

onSelectSalesPerson: function(model){
model.get('selectSalesPerson');

},


anyone knows what I have to do?

skirtle
28 Nov 2011, 6:41 AM
Shouldn't this:


this.onSelectSalesPerson().setDisabled(false);

be this?


this.selectSalesPerson.setDisabled(false);

Dannesart
28 Nov 2011, 6:48 AM
omg, i feel so stupid... you're right!
But now I only can enable it, if I want to disable it again?

skirtle
28 Nov 2011, 7:10 AM
Try:


onCreateSalesSelected: function(checkbox, checked) {
this.selectSalesPerson.setDisabled(!checked);
},

Dannesart
28 Nov 2011, 7:16 AM
Thank you very much! it works!