Extjs4中的Form之radiogroup和checkboxgroup

Ext.onReady(function(){
	var textFomr = Ext.create("Ext.form.Panel",{
		title : "form中文本框选框的实例",
		bodyStyle :'padding:5 5 5 5',
		frame : true,
		height : 250,
		width : 400,
		id:'my_form',
		renderTo:'formDemo',
		defaults:{
			labelSeparator :": ",
			labelWidth : 50,
			width : 200,
			allowBlank: false,
			msgTarget : 'side',
			labelAlign:'left'
		},
		items:[{
			xtype:'radiogroup',//单选分组
			fieldLabel:'性别',
			columns:2,
			items:[{
					xtype:'radiofield',
					boxLabel :'男',
					inputValue:'m',
					checked:true,
					name:'sex'
				},{
					xtype:'radiofield',
					boxLabel :'女',
					inputValue:'w',
					name:'sex'
				}]
			},{
				xtype:'checkboxgroup',//多选分组
				fieldLabel:'爱好',
				width:335,
				columns:4,	//几列
			items:[{
					xtype:'checkboxfield',
					inputValue:'1',
					name:'hobby',
					boxLabel:'唱歌'
				},{
					xtype:'checkboxfield',
					inputValue:'2',
					name:'hobby',
					boxLabel:'看书'
				},{
					xtype:'checkboxfield',
					inputValue:'3',
					name:'hobby',
					checked:true,
					boxLabel:'编程'
				},{
					xtype:'checkboxfield',
					inputValue:'4',
					name:'hobby',
					boxLabel:'交友'
			}]
		}],
		dockedItems:[{
			xtype:'toolbar',
			dock:'top',
			items:[{
				text:'选择全部的爱好',
				iconCls:'table_comm',
				handler:function(){
				  	var formObj = Ext.getCmp("my_form");
				  	var basic = formObj.getForm();
				  	var fields = basic.getFields();
				  	fields.each(function(field){
				  		if("hobby" == field.getName()){
				  			field.setValue(true)
				  		}
				  	})
				}
			}]
		}],
		buttons: [
		  {text:'登陆系统',handler:function(b){
		  	var formObj = Ext.getCmp("my_form");
		  	var basic = formObj.getForm();
		  		console.log(basic.getValues());
		  }}]
	})
})






  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值