您的位置:首页 > Web前端 > JavaScript

ExtJS 获取radioGroup及CheckboxGroup值

2015-11-05 22:37 519 查看
/*!
* Ext JS Library 3.3.0
*/
Ext.onReady(function(){

Ext.QuickTips.init();
Ext.form.Field.prototype.msgTarget = 'side';

/*====================================================================
* RadioGroup examples
*====================================================================*/
var radioGroup = {
xtype: 'fieldset',
title: 'Radio Groups',
autoHeight: true,
items: [{
xtype: 'radiogroup',
fieldLabel: 'Auto Layout',
items: [
{boxLabel: 'A', name: 'rb-auto', inputValue: 'A'},
{boxLabel: 'B', name: 'rb-auto', inputValue: 'B', checked: true},
{boxLabel: 'C', name: 'rb-auto', inputValue: 'C'},
{boxLabel: 'D', name: 'rb-auto', inputValue: 'D'},
{boxLabel: 'E', name: 'rb-auto', inputValue: 'E'}
]
}]
};
/*====================================================================
* CheckGroup example
*====================================================================*/
var checkGroup = new Ext.form.CheckboxGroup({
xtype: 'checkboxgroup',
fieldLabel: 'Auto Layout',
items: [
{boxLabel: 'A', name: 'A' },
{boxLabel: 'B', name: 'B' , checked: true},
{boxLabel: 'C', name: 'C' },
{boxLabel: 'D', name: 'D' },
{boxLabel: 'E', name: 'E' }
]
});

var fp = new Ext.FormPanel({
title: 'Check/Radio Groups Example',
frame: true,
labelWidth: 110,
width: 600,
renderTo:'form-ct',
bodyStyle: 'padding:0 10px 0;',
items: [radioGroup,checkGroup],
buttons: [{
text: 'RadioGroup',
handler: function(){
alert(fp.getForm().getValues()["rb-auto"]);
alert(fp.getForm().findField("rb-auto").getGroupValue());
}
},{
text: 'CheckBoxGroup',
handler: function(){
var ids = [];
var cbitems = checkGroup.items;
for (var i = 0; i < cbitems.length; i++) {
if (cbitems.itemAt(i).checked) {
ids.push(cbitems.itemAt(i).name);
}
}
alert(ids);
}
}]
});
});
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: