comboBox动态加载数据并支持多选(checkbox)

function getTableName(){//获取后台数据,即要动态加载的数据
	tableExportAction.getTableName(function(data){
		   tableStore=data;  
//		   allcomb = [['全部','全部']];
//	       tableStore.unshift(allcomb[0]);
		   tstore= new Ext.data.SimpleStore({fields :['value','name'], data :tableStore });
	})
}

var CheckBoxGroupTypes;
function getColName(pid,name){//这个方法是在选择checkbox的时候要在panel2中显示的数据
	tableExportAction.getColName(pid,function(data){  
		
		var items=[];
		var chk;
		for(var i=0;i<data.length;i++){
			chk = {boxLabel: data[i][1], name: data[i][0]+ '#' + data[i][1]};
  			items.push(chk);
		}
		
		  var FieldSetTypes = new Ext.form.FieldSet(
			  {   
				  id:'fieldSet'+pid,
				  name:'fieldSet'+pid,
				  items:[
					 CheckBoxGroupTypes = new Ext.form.CheckboxGroup({ 
					   		fieldLabel: name, 
							id:'columnName'+pid, 
							name:'columnName'+pid,
					        columns: 5, 
					        anchor:"95%",
					        items: items
					})
				  ]
			  });
			  panel2.items.add(FieldSetTypes);
			  panel2.doLayout();  
					
    });
}

var indexValue;
var index;
var flag=1;
function getForm(){
	
	var tableComBo = getComBox('tableName','表名称',tstore,50,false,3)
//  tableComBo.on('select', selectAll, this);
    tableComBo.on('select',function(combo, record, idx){
    	var tmp = Ext.get('fieldSet'+record.data.value);
    	if(tmp!=null) {//判断此对象是否存在,为了保证只加载一次并且在去掉选择的时候移除之前的显示值
    		panel2.remove('fieldSet'+record.data.value);
    	} else {
    		getColName(record.data.value,record.data.name);
    	}
    });
    
    panel1 = new Ext.Panel({
		labelWidth :120,
		frame : true,
		id:'panel1',
		autoHeight : true,
		bodyStyle : 'padding:5px 5px 0',
		layout : 'column',
		defaults : {
			labelAlign : 'right'
		},
		items: [	       
		    	{
					columnWidth : .5,
					layout : 'form',
					border : false,
					items : [{
						fieldLabel : 'Excel名称',
						xtype:'textfield',
						name : 'excelName',
						id : 'excelName',
						allowBlank : false,
						maxLength : 15,
						style : "margin-top:1px"
					}]
				},
				{
		        columnWidth: .4,
		        layout: 'form',
		        border: false,
		        items: [
		     	  		tableComBo
			        ]
		    	}]
	});
   
	panel2 = new Ext.Panel({
		labelWidth :80,
		frame : true,
		id:'panel2',
		autoHeight : true,
		bodyStyle : 'padding:5px 5px 0',
		items: []
	});
	
	return new Ext.FormPanel({
		labelWidth :120,
		frame : true,
		id:'myForm',
		autoHeight : true,
		bodyStyle : 'padding:5px 5px 0',
		defaults : {
			labelAlign : 'right'
		},
		items: [ panel1,panel2 ]
	});
}

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值