extjs的radiogroup单选按钮获取选中值的方法

在Ext.form.FormPanel的items中可以创建radiogroup的组件并贴出部分代码如下:

items:[{
	xtype:'radiogroup',
	fieldLabel: '校区类型',
	name:'RadiosType',//设置radiogroup的默认值,可以在Struts2的Action中创建一个名称和xtype的name一样的属性
	labelStyle:'text-align:right;',
	cls: 'x-check-group-alt',
	items:[
                {boxLabel: '总部', name: 'AddForm_sType',inputValue:'总部'},
                {boxLabel: '片区', name: 'AddForm_sType',inputValue:'片区'},
                {boxLabel: '校区', name: 'AddForm_sType',inputValue:'校区'},
	]
}]
{boxLabel: '总部', name: 'AddForm_sType',inputValue:'总部'},//这里的name表示的是获取radiogroup选中的值,并创建一个名称和radiogroup的items的name一样的属性                                                     
boxLabel//表示的是复选框旁边显示的文本   inputValue//传递参数,即选中该选项时,向外界传递的参数
var sTypeRadio = this.ownerCt.ownerCt.form.findField("AddForm_sType").getGroupValue();//获取单选按钮选中的值                              this.ownerCt.ownerCt//这里表示的是FormPanel的对象,自己定义!                                        

如下图所示:

你可能感兴趣的:(ExtJs)