ExtJS 获取radioGroup及CheckboxGroup值

来源:互联网 发布:台湾网络电视在线直播 编辑:程序博客网 时间:2024/05/16 15:49
/*! * 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);            }        }]    });});

0 0