单选框:
{
xtype: 'radiogroup',
fieldLabel: '性别',
defaults:{width:1},
items: [
{boxLabel: '男', name: 'rb-auto', inputValue: 1},
{boxLabel: '女', name: 'rb-auto', inputValue: 2, checked: true}
]
}
多选框:
{
fieldLabel:" 兴趣爱好",
xtype: 'checkboxgroup',
items: [
{boxLabel: '电脑', id: 'cb-auto-1'},
{boxLabel: '中国象棋', id: 'cb-auto-2', checked: true},
{boxLabel: '游泳', name: 'cb-auto-3'},
{boxLabel: '台球', name: 'cb-auto-4'},
{boxLabel: '旅游', name: 'cb-auto-5'}
]
}
单选框呢 看我的博客 [url]http://babydeed.iteye.com/admin/blogs/661862[/url]
复选框呢 一个例子:
[code="java"]Ext.onReady(function(){
var myCheckboxGroup = new Ext.form.CheckboxGroup({
id:'myGroup',
xtype: 'checkboxgroup',
renderTo :'form-cb',
fieldLabel: 'Single Column',
itemCls: 'x-check-group-alt',
columns: 3,
items: [
{boxLabel: '唱歌', name: '1'},
{boxLabel: '游泳', name: '2', checked: true},
{boxLabel: '看书', name: '3'},
{boxLabel: '旅游', name: '4'},
{boxLabel: '游戏', name: '5'},
{boxLabel: '睡觉', name: '6'}
]
});
//CheckboxGroup取值方法
for (var i = 0; i < myCheckboxGroup.items.length; i++)
{
if (myCheckboxGroup.items.itemAt(i).checked)
{
alert(myCheckboxGroup.items.itemAt(i).name);
}
}
});[/code]
单选: Ext.getCmp("id").getValue().inputValue;
多选:Ext.getCmp("id").eachItem(function(item){
if(item.checked)
{
alert(item.boxLabel);
}
})
是前台,还是后台?
后台直接根据name 读取就可以的,CheckboxGroup 应该是个数组的 。
单选直接取value,多选有一个是显示字段,一个是值字段,(二者很类似于value和key的关系)
剩下自己去API查