日期:2014-05-16  浏览次数:20355 次

ext js tree 带搜索(支持树枝节点和叶子节点)+ 大select(mutiple)
<%@page language="java" import="java.util.*" pageEncoding="UTF-8" %>
<%@include file="/common/path_header.jsp" %>
<%@include file="/common/grid_header.jsp" %>
<%@include file="/common/ext_header.jsp" %>
<html>
    <head>
        <title>账户树</title>
		<script src="${path}/script/jquery/jquery.js" type="text/javascript"></script>
        <script type="text/javascript">
            var obj = window.dialogArguments;
        	var retVal = "";
        	var selectDept  = "";//当前被点击的部门
        	var singleSelect = obj.singleSelect;
        	var areadySelectusersName = obj.areadySelectusersName;//所有用户名
        	var areadySelectusersId = obj.areadySelectusersId;//所有用户id
        	var areadySelectusersEmail = obj.areadySelectusersEmail;//所有email
            //异步树节点数据请求
            var requestConfig = {
                url : obj.treeUrl,
                callback: function(options, success, response){
                    acctInfo = Ext.decode(response.responseText);
                    var acctTree = Ext.getCmp("acct-tree");
                    acctTree.root.appendChild(acctInfo);
                    acctTree.expandAll();
                }
            };
            Ext.Ajax.request(requestConfig);
            
            AcctPanel = function(){
                AcctPanel.superclass.constructor.call(this, {
                    id: 'acct-tree',
					checkModel:'cascade',
                    split: true,
                    header: false,
                    width: 280,
                    minSize: 175,
                    maxSize: 500,
                    collapsible: true,
                    margins: '0 0 5 5',
                    cmargins: '0 0 0 0',
                    rootVisible: false,
                    lines: false,
                    autoScroll: true,
                    animCollapse: false,
                    animate: false,
                    collapseMode: 'mini',
                    loader: new Ext.tree.TreeLoader({
                        preloadChildren: true,
                        clearOnLoad: false
                    }),
                    root: new Ext.tree.AsyncTreeNode({
                        text: 'Ext JS',
                        id: 'root',
                        expanded: true,
                        children: []
                    }),
                    collapseFirst: false,
                    listeners: {
						'click':function (node){
						    selectDept = node.text;
							jQuery.ajax({
					            url: path + '/productpool/findUserTreeAll.do',
					            type: "post",
					            data: {
					                deptids: node.id
					            },
					            dataType: "json",
					            success: function(d){
					                 var $select1 = jQuery("#select1");
					                 $select1.html("");//先清空已有数据
					                 jQuery.each(d.children,function (k,v){
					                     var uid = v.id;
					                     var uname = v.text;
					                     var option = jQuery('<option value="'+uid+'">'+uname+'</option>');
					                     option.attr("title",v.email);
						                 $select1.append(option);
					                 });
					            },
					            error: function(a, b, c){
									jQuery.ligerDialog.error(b);
					            }
					        });
						},
                        'checkchange': function(node, checked){
                            //树节点checked事件监听
                            //处理所有父节点
                            node.cascade(function(node){
                                node.attributes.checked = checked;
                                node.ui.checkbox.checked = checked;
								if(retVal.indexOf(node.id)<0)//去重复
								   retVal += node.id + "|" + node.text+",";