PDA

View Full Version : Checkbox fires



stoneboys
16 Jan 2012, 4:28 AM
Hi all, I want create fires on checkbox..
this my case :
I have one checkbox & one textfield , If Checkbox values = 1 OR Checkbox event change The Textfield is enable but if Checkbox values = 0 the Textfield is disable ?


thank before.

findajit
16 Jan 2012, 5:41 AM
Here is how you can achieve it:


Ext.create('Ext.form.Panel', {
renderTo: Ext.getBody(),
items: [{
xtype: 'checkbox',
boxLabel: 'Check This',
listeners: {
change: function(fld, newVal, oldVal, opts) {
if (newVal)
fld.up('panel').down('textfield').enable();
else
fld.up('panel').down('textfield').disable();
}
}
}, {
xtype: 'textfield',
labelText: 'Text',
disabled: true
}]
});

stoneboys
16 Jan 2012, 9:54 AM
Here is how you can achieve it:


Ext.create('Ext.form.Panel', {
renderTo: Ext.getBody(),
items: [{
xtype: 'checkbox',
boxLabel: 'Check This',
listeners: {
change: function(fld, newVal, oldVal, opts) {
if (newVal)
fld.up('panel').down('textfield').enable();
else
fld.up('panel').down('textfield').disable();
}
}
}, {
xtype: 'textfield',
labelText: 'Text',
disabled: true
}]
});


thanks my problem is resolved, but i make litle change here, this my code :


Ext.create('Ext.form.Panel', {
renderTo: Ext.getBody(),
items: [{
xtype: 'checkbox',
boxLabel: 'Check This',
listeners: {
change: function(fld, newVal, oldVal, opts) {
val = fld.disabled==true;
if (newVal && val)
fld.up('panel').down('textfield').enable();
else
fld.up('panel').down('textfield').disable();
}
}
}, {
xtype: 'textfield',
labelText: 'Text',
disabled: true
}]
});


this my code :



val = fld.disabled==true;
if (newVal && val)


i use it because some checkbox already checked & current disabled,this on case if we just need edit some datas..

thanks findajit..