PDA

View Full Version : Disable / Enable a trigger in triggerfield



olakara
24 Jan 2012, 3:55 AM
I have a trigger field as follows:



xtype: 'triggerfield',
emptyText: 'click the trigger',
trigger1Cls:'x-form-search-trigger',
trigger2Cls:'x-form-view-trigger',
allowBlank: false,
onTrigger1Click : function() {
// action for search
},
onTrigger2Click : function() {
// action for dropdown
}


Now, in my form I have a condition where-in I need to disable the search trigger (trigger1Cls).. how do I disable the specific trigger alone and later enable it?

jay@moduscreate.com
24 Jan 2012, 9:11 AM
Relative to a combo:

var c = new Ext.form.field.ComboBox({
renderTo : Ext.getBody(),
store : ['blah','blah blah']
});
c.triggerEl.elements[0].addCls('x-item-disabled')

olakara
25 Jan 2012, 12:38 AM
That would just apply the CSS. Users will be able to still click and invoke the action method. I am looking for disabling the listener methods as well.
Since, I didn't get any one shot solution, I am currently handling the functionality as:
1. Add / Remove the "x-item-disabled" CSS class.
2. Handle the execution of code at listener methods by look at the trigger's state.

Any other way to handle this situation?

tvanzoelen
25 Jan 2012, 2:17 AM
You could do


this.triggerEl.elements[0].mask();

and on click check if it is masked with



this.triggerEl.elements[0].isMasked();