bradyisom
18 Aug 2009, 2:24 PM
I have a set of individual radio buttons (not in a radio group). A part of the code is below:
xtype: 'fieldset',
title: 'Type',
forceLayout: true,
autoHeight: true,
hideLabels: true,
items: [{
xtype: 'radio',
id: 'qTypeChoice',
inputValue: 'choice',
name: 'qtype',
boxLabel: 'Mulitple Choice',
listeners: {
check: changeQuestionTypeCheck
}
}, {
xtype: 'radio',
inputValue: 'text',
name: 'qtype',
boxLabel: 'Short Answer',
listeners: {
check: changeQuestionTypeCheck
}
}, {
xtype: 'radio',
inputValue: 'essay',
name: 'qtype',
boxLabel: 'Essay',
listeners: {
check: changeQuestionTypeCheck
}
}, {
xtype: 'radio',
inputValue: 'match',
name: 'qtype',
boxLabel: 'Matching',
listeners: {
check: changeQuestionTypeCheck
}
}, {
xtype: 'radio',
inputValue: 'answer',
name: 'qtype',
boxLabel: 'Multiple Answer',
listeners: {
check: changeQuestionTypeCheck
}
}]
My changeQuestionTypeCheck function is called just fine when the user clicks on the radio buttons. However, when I make something like the following call from code:
Ext.getCmp('qTypeChoice').setValue('answer');
the "checked" property on the DOM does not get cleared on sibling radio buttons and results in a bug similar to http://extjs.com/forum/showthread.php?t=39991. It seems like the setValue function of Ext.form.Radio should be something like the following to match the behavior of the onClick function:
Ext.override(Ext.form.Radio, {
setValue : function(v){
if (typeof v == 'boolean') {
Ext.form.Radio.superclass.setValue.call(this, v);
} else {
var els = this.getCheckEl().select('input[name=' + this.el.dom.name + ']');
els.each(function(el){
if(el.dom.value == v){
Ext.getCmp(el.dom.id).setValue(true);
}else{
Ext.getCmp(el.dom.id).setValue(false);
}
}, this);
}
return this;
}
});
xtype: 'fieldset',
title: 'Type',
forceLayout: true,
autoHeight: true,
hideLabels: true,
items: [{
xtype: 'radio',
id: 'qTypeChoice',
inputValue: 'choice',
name: 'qtype',
boxLabel: 'Mulitple Choice',
listeners: {
check: changeQuestionTypeCheck
}
}, {
xtype: 'radio',
inputValue: 'text',
name: 'qtype',
boxLabel: 'Short Answer',
listeners: {
check: changeQuestionTypeCheck
}
}, {
xtype: 'radio',
inputValue: 'essay',
name: 'qtype',
boxLabel: 'Essay',
listeners: {
check: changeQuestionTypeCheck
}
}, {
xtype: 'radio',
inputValue: 'match',
name: 'qtype',
boxLabel: 'Matching',
listeners: {
check: changeQuestionTypeCheck
}
}, {
xtype: 'radio',
inputValue: 'answer',
name: 'qtype',
boxLabel: 'Multiple Answer',
listeners: {
check: changeQuestionTypeCheck
}
}]
My changeQuestionTypeCheck function is called just fine when the user clicks on the radio buttons. However, when I make something like the following call from code:
Ext.getCmp('qTypeChoice').setValue('answer');
the "checked" property on the DOM does not get cleared on sibling radio buttons and results in a bug similar to http://extjs.com/forum/showthread.php?t=39991. It seems like the setValue function of Ext.form.Radio should be something like the following to match the behavior of the onClick function:
Ext.override(Ext.form.Radio, {
setValue : function(v){
if (typeof v == 'boolean') {
Ext.form.Radio.superclass.setValue.call(this, v);
} else {
var els = this.getCheckEl().select('input[name=' + this.el.dom.name + ']');
els.each(function(el){
if(el.dom.value == v){
Ext.getCmp(el.dom.id).setValue(true);
}else{
Ext.getCmp(el.dom.id).setValue(false);
}
}, this);
}
return this;
}
});