¿Cómo escuchar si un radiobutton se verifica con extjs?
-
27-10-2019 - |
Pregunta
{xtype : 'radiogroup',
items : [{
boxLabel : 'jjj',
name : 'tyutrfytr',
inputValue : 1,
checked : true
}, {
boxLabel : 'kkk',
name : 'dfdsfdsddd',
inputValue : 2,
listeners: {
check : function(cb, rec, ind) {
alert('hhhh');
}
}
}]
}
El código anterior da alert
No importa si presiono la primera opción o la segunda opción. ¿No debería alertar solo cuando la segunda opción esté marcada?
Solución
El evento se dispara cada vez que la radio se verifica o no se controla.
Verifique: (ext.Form.Checkbox esto, boolean marcado) se dispara cuando la casilla de verificación se verifica o no se verifica. Los oyentes serán llamados con los siguientes argumentos: esto: ext.form.eckbox Esta casilla de verificación verificada: boolean El nuevo valor marcado
listeners: {
check : function(cb, value) {
if (value) alert('check');
else alert('uncheck');
}
}
Otros consejos
Este código funciona bien en la versión 4.2:
xtype: 'radiogroup',
id: 'RadioGroupId',
fieldLabel: 'The Radio Group',
items: [{
xtype: 'radiofield',
boxLabel: 'The first radio',
id: 'FirstRadioId',
name: 'radios',
inputValue: 1,
listeners: {
change: function (cb, newValue, oldValue) {
if (newValue) {
// First radio button has been selected
} else {
// Second radio button has been selected
}
}
}
}, {
xtype: 'radiofield',
boxLabel: 'The second radio',
id: 'SecondRadioId',
name: 'radios',
inputValue: 2,
checked: true
}]
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow