PDA

View Full Version : Change triggerCls on a rendered trigger field



mx_starter
7 Jan 2013, 5:08 AM
Well guys, can you tell me is that possible?



Ext.define('Ext.ux.FlagTrigger', {
extend: 'Ext.form.field.Trigger',
triggerCls: 'sbg-flagTrigger-EN',

onTriggerClick: function() { this.triggerCls = 'sbg-flagTrigger-FR'; }

});

sbg-flagTrigger-EN and sbg-flagTrigger-FR simply use different flag images.

In my case - the triggerCls property itself gets changed, but the rendered trigger image does not.
(the console does not show any network request for the other file)

There is no such method as setTriggerCls (like setIconCls for example presented in other components).

So is it possible to dynamically change the trigger style on a rendered trigger field?

And if so - which is the way for doing that?

Thanks.

droessner
7 Jan 2013, 6:22 AM
You can do this by changing the class of the actual trigger element. Something like this should work:


Ext.define('Ext.ux.FlagTrigger', {
extend: 'Ext.form.field.Trigger',
triggerCls: 'sbg-flagTrigger-EN',
onTriggerClick: function() {
this.triggerEl.elements[0].removeCls('sbg-flagTrigger-EN').addCls('sbg-flagTrigger-FR');
}
});

mx_starter
7 Jan 2013, 6:28 AM
You can do this by changing the class of the actual trigger element. Something like this should work:


Ext.define('Ext.ux.FlagTrigger', {
extend: 'Ext.form.field.Trigger',
triggerCls: 'sbg-flagTrigger-EN',
onTriggerClick: function() {
this.triggerEl.elements[0].removeCls('sbg-flagTrigger-EN').addCls('sbg-flagTrigger-FR');
}
});


=D>
Thanks, mate. Saved me just on time. Started to write a different solution a minute ago.
That is why the forum is for.

Any issue to post your suggestion on the API comments?