Extjs RadioBox 单选

本文介绍如何在ExtJS中实现两个单选按钮的互斥选择,并通过监听事件来更新隐藏字段的值,以便后台能够获取到正确的选项状态。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

// 两个radio 只是显示,两个具有互斥性,触发事件时给一个隐藏字段赋值,后台读取隐藏字段,肯定不是最优,望高手拍砖

this.cntRadio = new Ext.form.Radio({
        id: 'cntRadioId',
        boxLabel: '数量',
        inputValue: 'cnt',
        listeners: {
            'check': function() {
                //alert(this.getValue());
                if (this.getValue()) {
                    Ext.getCmp('moneyRadioId').setValue(false);
                    this.setValue(true);
                    Ext.getCmp('aresultType').setValue('cnt');
                }
            }
        }
});
 this.moneyRadio = new Ext.form.Radio({
        id: 'moneyRadioId',
        boxLabel: '总投资',
        inputValue: 'money',
        listeners: {
            'check': function() {
                if (this.getValue()) {
                    Ext.getCmp('cntRadioId').setValue(false);
                    this.setValue(true);
                    Ext.getCmp('aresultType').setValue('totalMoney');
                }
            }
        }
});

 this.formPanel = new Ext.form.FormPanel({
      baseCls: 'x-plain',
      frame: false,
      id: id,
      bodyStyle: 'padding:5px 12px',
      url: 'Station.aspx?ac=Analysis',
      items: [{
                xtype: 'hidden',
                id: 'agroupType',
                value: 'country'
            }, {
                xtype: 'radiogroup',
                fieldLabel: '统计结果',
                id: 'resultRadio',
                items: [
                    this.cntRadio, this.moneyRadio
                ]
          }]

});

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值