在下拉框中显示一个多选的树



主要代码如下:
//在日志中发送短信--------------------------------
			var calendar_department = new Ext.form.ComboBox({
			id : 'calendar_department',
				store : new Ext.data.SimpleStore({
							fields : [],
							data : [[]]
						}),
				editable : false,
				mode : 'local',
				triggerAction : 'all',
				maxHeight: 200, 
				name : 'departments',
				width : 340,
				tpl : "<tpl for='.'><div style='height:200px'><div id='tree'></div></div></tpl>",
				selectedClass : '',
				fieldLabel : '接收人',
				layerHeight : 120,
				onSelect : Ext.emptyFn
			});
			
			var tree = new Ext.tree.TreePanel({
						animate : true,
						border:false, 
						collapsible : true,
						enableDD : true,
						enableDrag : true,
						rootVisible : false,
						autoScroll : true,
						width : 150,
						lines : true
					
						 
					});
			// 根节点
			var root = new Ext.tree.AsyncTreeNode({
						id : "root",
						text : "根节点",
						draggable:false,  //不能拖动
						checked : false,
						loader: new Ext.tree.TreeLoader({   
			            	dataUrl:'../getUserList.do'  
			        	})
			        	
			        	
					});
			
			tree.setRootNode(root);
			
			tree.on('checkchange', function(node, checked){
			                    node.expand();
			                    node.attributes.checked = checked;
			                    node.eachChild(function(child){
			                        child.ui.toggleCheck(checked);
			                        child.attributes.checked = checked;
			                        child.fireEvent('checkchange', child, checked);
			                    });
			                },tree);
			
			
			tree.on('checkchange',function(){
					 var b = tree.getChecked();
			         var checkid = new Array;// 存放选中值的数组
			         for (var i = 0; i < b.length; i++) {
			         	checkid.push(b[i].text);// 添加选中值到数组
			         }
			        calendar_department.setValue(checkid.toString());
			}
			);
			
			calendar_department.on("expand", function() {
						tree.render("tree");
					});
					
		
		
		
			var calendarSMSForm = new Ext.FormPanel({
				id : 'calendarSMSForm_id',
				title : '',
				width : '100%',
				height : '320',
				layout : 'form',
				// autoHeight:'true',
				labelAlign : 'right',
				frame : true,

				labelWidth : 70,
				items : [
							calendar_department,{
							xtype : 'textarea',
							id : 'calendarSMSCustom_id',
							fieldLabel : '自定义号码',
							name : 'smsCustom',
							height : '90',
							width : '90%'

						}, {

							xtype : 'textarea',
							id : 'calendarSMScontent_id',
							fieldLabel : '信息内容',
							name : 'smscontent',
							height : '100',
							width : '90%',
							allowBlank : false,
							blankText : '信息内容必须填写'

						}, {
							buttons : [{
								text : '发送',
								handler : function() {
									calendarSMSWin.hide();
									var f = calendarSMSForm;

									if (f.form.isValid()) {
										f.form.doAction('submit', {

											// -----------
											url : '../SMSAction.do',
											method : 'post',
											params : '',
											success : function(form, action) {
												// TODO ---625
												Ext.Msg.alert('提示窗口',
														'正在发送中...!');
												// business_store.load();
											},
											failure : function(form, action) {
												win.show();
												var obj = Ext.util.JSON
														.decode(action.response.responseText);
												Ext.Msg.alert('提示窗口',
														obj.errors);
											}

										})
										
									}
								}
							}, {
								text : '取消',
								handler : function() {
									var f = calendarSMSForm;
									f.form.reset();
								}
							}]
						}]
			});
			
			
			   calendarSMSWin = new Ext.Window({ title: "短信息发送" , width: 500 , height:
			  330 , buttonAlign:'center', layout: 'fit', plain:true,
			  resizable:false, frame : true, closeAction:'hide',
			  bodyStyle:'padding:5px;', items : calendarSMSForm
			  
			  }); 



你可能感兴趣的:(json,UI,ext,F#)