概述
A Ext.form.FieldContainer which has a specialized layout for arranging Ext.form.field.Radio controls into columns, and provides convenience Ext.form.field.Field methods for getting, setting, and validating the group of radio buttons as a whole.
一个表单字段容器 Ext.form.FieldContainer 有一个特定的布局 排列单选按钮Radio字段(Ext.form.field.Radio)以列方式,提供了方便的Ext.form.field.Field字段方法获取、设置和校验一组radio单选框按钮作为一个整体。
布局
The default layout for RadioGroup makes it easy to arrange the radio buttons into columns; see the columns and vertical config documentation for details. You may also use a completely different layout by setting the layout to one of the other supported layout types; for instance you may wish to use a custom arrangement of hbox and vbox containers. In that case the Radio components at any depth will still be managed by the RadioGroup’s validation.
默认的radioGroup布局很简答的安排radio按钮列布局。查看columns 和 vertical配置文件了解更多。你也可以使用一个完全不同的布局通过设置一个其他支持的布局;例如你可以使用自定义的排列 使用 hbox 和 vbox容器。在这种情况下 Radio组件依然被 RadioGroup的校验管理。
注意 一个radiogroup下的组件 name配置项一定要一样,这样同时就只能选中一个按钮,切换时其他的按钮就不会还是选中状态。
更正(监听事件):这个是在单radio下,几个单radio放到了Ext.form.FieldContainer中测试的。所以监听选中的值是true or false代表有没有选中radio。
每个子组件的都可以监听事件,如下,其中change事件的回调函数的第二参数newValue,在选中该按钮选项时是true,切换到其他单选按钮时回调是false。(仅仅失去焦点不回调)
查看总结5描述
例子:
items: [
{ boxLabel : '管理模式',name : 'basic_mode',inputValue: 'route',id : 'basic_mode_1', width:80, checked:(rec.mode=='route'),
listeners:
{
change:
{
fn: function(me, newValue, oldValue)
{
//
}
}
}
},
{ boxLabel : '镜像模式',name : 'basic_mode',inputValue: ((rec.mode=='mirror' || rec.engin_mode=='mirror')?'mirror':'bridge'),id : 'basic_mode_2', width:80, checked:(rec.mode=='mirror'||rec.mode=='bridge')},
{ boxLabel : '直通模式',name : 'basic_mode',inputValue: ((rec.mode=='bridge' )?'bridge':'bridge'),id : 'basic_mode_3', width:80, checked:(rec.mode=='bridge')},
{ boxLabel : '牵引模式',name : 'basic_mode',inputValue: ((rec.mode=='pull')?'pull':'bridge'),id : 'basic_mode_4', width:80, checked:(rec.mode=='pull')
}
]
注意,这里的 name属性值,就是提交表单提交的参数,inputValue就是其值
如: name: ‘addr’
inputValue:‘ipv4’
那么 那么表单提交的参数就是abbr=ipv4
这里对比ComboBox下拉菜单组件,
name一样是对应的提交参数,它的值由valueField指定是那个field
// xtype:'JComboBox',
// name:'family',
// fieldLabel: '类型',
// store:Ext.create('Ext.data.Store', {
// fields: ['abbr', 'name'],
// data : [
// {"abbr":"ipv4", "name":"IPV4"},
// {"abbr":"ipv6", "name":"IPV6"}
// ]
// }),
// value:'ipv4',
// labelWidth: 110,//标签宽度
// queryMode: 'local',
// displayField: 'name',
// valueField: 'abbr',
//RadioGroup
{
xtype:'JRadioGroup',
fieldLabel: '状态',
id: 'basic_state',
//labelWidth: 110,
columns : [100,100],
items:[{
boxLabel: '启用',
name: 'basic_state',
inputValue: 'up',
checked: (rec.state == 'up')?true:false
},{
boxLabel: '禁用',
name: 'basic_state',
inputValue: 'down',
checked: (rec.state == 'down')?true:false
}]
},
//ComboBox
{
xtype: 'JComboBox',
fieldLabel: '状态',
store: Ext.create('Ext.data.Store',
{
fields: ['value', 'name'],
data :
[
{"value":"up", "name":"启用"},
{"value":"down", "name":"禁用"}
]
}),
value: rec.state,
queryMode: 'local',
displayField: 'name',
valueField: 'value',
id: 'basic_state',
name: 'basic_state'
},
xtype:'RadioGroup',
fieldLabel: '类型',
labelWidth: 110,
columns : [60,60],
items:[{
change ( this , newValue , oldValue , eOpts )
Fires when the value of a field is changed. The value of a field is checked for changes when the field's setValue method is called and when any of the events listed in checkChangeEvents are fired.
PARAMETERS
this : Ext.form.field.Field
newValue : Object
The new value
oldValue : Object
The original value
eOpts : Object
The options object passed to Ext.util.Observable.addListener.