I have a checkbox that controls 4 dateFields in ExtJs. I want to be able to give them a common property to be able to disable all fields with one command. I assume there is a simpler way to do that. It works, but its a big block of code.
This is the checkBox's change event implementation so far:
change: function (cmp, newValue, oldValue, eOpts) {
var dt1 = cmp.up().down('#Dtf1');
dt1.setDisabled(newValue);
var dt2 = cmp.up().down('#Dtf2');
dt2.setDisabled(newValue);
var dt3 = cmp.up().down('#Dtf3');
dt3.setDisabled(newValue);
var dt4 = cmp.up().down('#Dtf4');
dt4.setDisabled(newValue); }
You can add an attribute for example:
{
xtype: 'textfieid',
itemId: 'Dtf1',
dtf: true
}
Then you'll be able to query like:
cmp.up().query('[dtf=true]').forEach(function(item){
item.setDisabled(newValue);
});
Or can also use a query, like:
cmp.up().query('#Dtf1, #Dtf2, #Dtf3, #Dtf4').forEach(function(item){
item.setDisabled(newValue);
});