checkbox多选

/*!
* Ext JS Library 3.2.1
* Copyright(c) 2006-2010 Ext JS, Inc.
* licensing@extjs.com
* http://www.extjs.com/license
*/

var CheckBoxGroupTypes = new Ext.form.CheckboxGroup({
xtype: 'checkboxgroup',
fieldLabel: '分机列表',
id:'name',
name :'name',
columns: 4,
itemCls: 'x-check-group-alt',
anchor:"95%",
msgTarget:"side",
allowBlank: false
});

function getData(){
$.ajax({
url:'phonesForJson',
type:'post',
dataType:'json',
success:function(response){
var phones = response.phones;
//var Str = "[";
var items=[];
$.each(response.phones,function(i,phone){
var chk = {boxLabel: phone.username, name: phone.username};
items.push(chk);
});
//添加CheckBoxGroupTypes内容
CheckBoxGroupTypes.items = items;
var fp = new Ext.FormPanel({
title: '播放音乐管理',
frame: true,
labelWidth: 110,
width: 600,
renderTo:'form-ct',
bodyStyle: 'padding:0 10px 0;',
items: [{
columnWidth:.5,//宽度为50%
xtype:"checkbox",
id:'chc',
boxLabel:"全选/全不选",//显示在复选框右边的文字
handler: function addFn(){
//alert(Ext.getCmp('chc').getValue());
var check = Ext.getCmp('chc').getValue();
var length = CheckBoxGroupTypes.items.getCount();
var all = new Array();
for (i = 0;i<length;i++){
all[i]=check;
}
CheckBoxGroupTypes.setValue(all);
}
},
CheckBoxGroupTypes
],
buttons: [{
text: '提 交',
handler: function(){
if(fp.getForm().isValid()){
var nums = fp.getForm().getValues(true).replace(/&/g,'').replace(/=on/g,' ');
fp.getForm().submit({
url : 'playMusicToTels?nums='+nums,// 请求的url地址
method : 'POST',// 请求方式
success : function(form, action) {
Ext.Msg.alert('提示','操作成功');
},
failure : function(form, action) {
Ext.Msg.alert('警告','操作失败,请返回重新操作');
}
});
}
}
},{
text: '重 置',
handler: function(){
fp.getForm().reset();
}
}]
});
}
});
}

Ext.onReady(function(){
Ext.QuickTips.init();
Ext.form.Field.prototype.msgTarget = 'side';
getData();

});
  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值