ExtJS多选到文本框

<script>
// 初始化Store
var allUser=new Array();
<%
	sql="select tui.User_ID, tui.User_Name, tui.Department_name from t_user_info tui where tui.User_ID in (select user_id from t_userole_info where role_id ='4' or role_id='5') order by tui.User_Name"
	set rs=db.execute(sql)
	do while not rs.eof
		str=rs("Department_name")
		if str<>"" then
			str_arr=split(str,"/")
			str=""
			if ubound(str_arr)<>-1 then
				for i=0 to ubound(str_arr)-1
					if i=ubound(str_arr)-1 then
						str=str&str_arr(i)
					else
						str=str&str_arr(i)&"/"
					end if
				next
			end if
		end if
		response.Write "allUser[allUser.length]={id:'"&rs("User_ID")&"',display:'"&rs("User_Name")&"--"&str&"'};"
		rs.movenext
	loop
	rs.close
%>
</script>

storeAllMan= new Ext.data.JsonStore({
		fields:['id', 'display'],
		data:allUser
});

var cc_users=new  Ext.form.ComboBox ({
		displayField:'display',
		valueField :'id',
		store : storeAllMan,
		hiddenName : 'userId',
	    typeAhead: true,
		mode: 'local',
		triggerAction: 'all',
		emptyText:'选中后回车添加到下边的列表中',
		width:400,
		allowBlank:true,
		selectOnFocus:true,
		forceSelection:true,
		renderTo :'cc_users'
    });
	cc_users.queryStr="";
    cc_users.on("beforequery",function(obj){
    	var qs=obj.query;
    	if(qs==cc_users.queryStr && cc_users.queryStr!=""){
    		obj.cancel=true;
    	}
    	cc_users.queryStr=qs;
    });
	cc_users.on('select',function(obj,record){
		addOption(record.data.id,record.data.display,"selected_users");
		obj.focus(true);
	});
	cc_users.on('specialkey',function(obj,e){
		if(e.getCharCode()==13)
			e.stopEvent();
	});

// 双击列表函数
function addOption(value,text){
	var obj=document.getElementById("selected_projects");
	if(isExist(value,obj))
		return;
	var option_obj=new Option(text,value);
	obj.options[obj.length]=option_obj;
	
}
function isExist(value,selectList){
	for(i=0;i<selectList.length;i++){
		if(selectList[i].value==value)
			return true
	}
	return false;
}
function del(s){
	if(s.selectedIndex==-1)return;
	s.options[s.selectedIndex]=null;
}

你可能感兴趣的:(sql,ext)