java checkbox ext_Ext Js4 CheckBox学习与实例 | 学步园

1:程序代码

String path = request.getContextPath();

String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";

%>

CheckBox

Ext.onReady(function() {

Ext.create('Ext.form.Panel', {

bodyPadding: 10,

width : 300,

title : '社会调查',

items: [

{

xtype : 'fieldcontainer',

fieldLabel : '您的爱好',

defaultType: 'checkboxfield',

items: [

{

boxLabel : '唱歌',

name : 'hobby',

inputValue: '1',

id : 'sing'

}, {

boxLabel : '跳舞',

name : 'hobby',

inputValue: '2',

checked : true,

id : 'dance'

}, {

boxLabel : '看书',

name : 'hobby',

inputValue: '3',

id : 'read'

}

]

}

],

bbar: [

{

text: '选择唱歌',

handler: function() {

var checkbox = Ext.getCmp('sing');

checkbox.setValue(true);

}

},

'-',

{

text: '全选',

handler: function() {

var checkbox1 = Ext.getCmp('sing'),

checkbox2 = Ext.getCmp('dance'),

checkbox3 = Ext.getCmp('read');

checkbox1.setValue(true);

checkbox2.setValue(true);

checkbox3.setValue(true);

}

},

{

text: '全不选',

handler: function() {

var checkbox1 = Ext.getCmp('sing'),

checkbox2 = Ext.getCmp('dance'),

checkbox3 = Ext.getCmp('read');

checkbox1.setValue(false);

checkbox2.setValue(false);

checkbox3.setValue(false);

}

},

{

text: '反选',

handler: function() {

var checkbox1 = Ext.getCmp('sing'),

checkbox2 = Ext.getCmp('dance'),

checkbox3 = Ext.getCmp('read');

if(checkbox1.getValue()) {

checkbox1.setValue(false);

} else {

checkbox1.setValue(true);

}

if(checkbox2.getValue()) {

checkbox2.setValue(false);

} else {

checkbox2.setValue(true);

}

if(checkbox3.getValue()) {

checkbox3.setValue(false);

} else {

checkbox3.setValue(true);

}

}

}

],

renderTo: Ext.getBody()

});

});

2:程序效果图

0_1312526968m0p0.gif

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值