`
ouyang86
  • 浏览: 2180 次
  • 性别: Icon_minigender_1
  • 来自: 深圳
社区版块
存档分类
最新评论

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();
   
});
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics