我在访问无线电组中所选单选按钮的值时遇到一些困难.基于论坛和网络上其他帖子的讨论,我尝试了许多不同的方法.不幸的是,没有足够的幸运(或熟练)让它工作.根据以下FormPanel配置,我希望有人可以告诉我如何在组"mainPhone"中获取所选无线电的值.
谢谢!
想要更新以表明我能够从stackoverflow获得响应,而EXT-JS论坛没有向我提供任何帮助.方法去stackoverflow!
马特
function createForm(elem) {
var myForm2 = new Ext.form.FormPanel({
renderTo:elem,
width:425,
frame:true,
style:"margin: 10px auto 10px auto;",
items: [{xtype:'fieldset',
title: 'Contact Info',
autoHeight:true,
items :[new Ext.form.RadioGroup({
fieldLabel: 'Main Phone',
vertical: false,
id:"mainPhone",
items: [
{boxLabel: 'Home', name: 'id-1', inputValue: 'H', checked:true},
{boxLabel: 'Work', name: 'id-1', inputValue: 'W'},
{boxLabel: 'Other', name: 'id-1', inputValue: 'O'}
]
}),
new Ext.form.TextField({
id:"frm_CreateCustomerHomePhone",
fieldLabel:"Home Phone",
width:275,
allowBlank:true
}),
new Ext.form.TextField({
id:"frm_CreateCustomerWorkPhone",
fieldLabel:"Work Phone",
width:275,
allowBlank:true
})
new Ext.form.TextField({
id:"frm_CreateCustomerOtherPhone",
fieldLabel:"Other Phone",
width:275,
allowBlank:true
})
]}]});
}
Run Code Online (Sandbox Code Playgroud)
小智 5
getValue()
无线电组本身的方法将返回被检查的对象,如果有的话,否则返回undefined.
(顺便说一下,我为我的盒子设置值而不是inputValue,虽然我认为它没有太大的区别,也许它在最后一个"getValue"上),我使用的是extjs 3.0,我的radiogroup配置是与你的略有不同.
var checkedItem = Ext.getCmp('mainPhone').getValue();
if (checkedItem == undefined) return '';
return checkedItem.getGroupValue();
// The getGroupValue will return the value of the checked option in a group,
// unfortunately, it only seems to work on the items and not the radiogroup
// itself
Run Code Online (Sandbox Code Playgroud)