• LigerTree的使用


    效果图:

    页面:

        <div id="divs" style=" 310px; overflow-x: hidden; overflow-y: hidden; border-radius: 10px; height: 420px; top: 80px; left: 520px; z-index: 100; position: absolute; border: 10px solid #FF5555; background-color: white;">
                <table style=" 100%; text-align: right;">
                    <tr>
                        <td><span id="Span1" style="cursor: pointer;" onclick="clad()">确定</span> <span id="gb" style="cursor: pointer; margin-right: 5px">关闭</span> </td>
                    </tr>
    
                </table>
                <div style=" 300px; height: 400px; margin-top: 0px; float: left; overflow-x: hidden; overflow-y: auto; border: 1px solid #ccc;">
                    <ul id="tree1">
    
                    </ul>
                </div>
            </div>

    js

        $(function () {
                $("#divs").hide();
                //t = $("#tree1").ligerTree({ checkbox: true });
    
                $("#gb").click(function () {
                    $("#divs").hide();
                });
    
                $("#TextBox2").ligerTextBox({  500 });
    
                $("#tree1").ligerTree({
                    nodeWidth: 300,
                    url: 'gongwenHandler.ashx?bz=tree&type=company',
              
                    checkbox: true,
                    idFieldName: 'id',
                    parentIDFieldName :'pid',
                    slide: false
                });
    
                manager = $("#tree1").ligerGetTreeManager();
            });
    
            function clad() {
                var notes = manager.getChecked();
                var text = "";
                for (var i = 0; i < notes.length; i++) {
                    if (notes[i].data.isparent == '2') {
                        var users = $("#hdToUsers").val() + notes[i].data.id + ','
                        $("#hdToUsers").val(users);
                        text += notes[i].data.text + " ";
                    }
                }
                $("#TextBox2").val(text);
                $("#divs").hide();
            }
    
            function showd() {
                $("#divs").show();
            }
    gongwenHandler.ashx 后台:
     //加载公司,部门,人员树。
                case "tree":
                    string type = context.Request.Params["type"];
                    string prev = context.Request.Params["prev"];
                    List<TreeNode> list = new List<TreeNode>();
                    if (type == "company")
                    {
                        DataTable danwei = EDU.DBUtility.DbHelperSQL.GetDataTable("select orgId_I,orgName_N from Organize");
                        //遍历公司
                        foreach (DataRow row in danwei.Rows)
                        {
    
                            TreeNode node = new TreeNode();
                            node.id = Convert.ToString(row["orgId_I"]);
                            node.pid = "0";
                            node.text = Convert.ToString(row["orgName_N"]);
                            node.isparent = "0";
                            
                            
                            list.Add(node);
    
                            //遍历出部门
                            DataTable depart = EDU.DBUtility.DbHelperSQL.GetDataTable("select ID,BuMenName from ERPBuMen  where suoshudanwei='" + Convert.ToString(row["orgId_I"]) + "'");
                            foreach (DataRow deptRow in depart.Rows)
                            {
                                TreeNode deptnode = new TreeNode();
                                deptnode.id = Convert.ToString(deptRow["ID"]);
                                deptnode.pid = Convert.ToString(row["orgId_I"]);
                                deptnode.text = Convert.ToString(deptRow["BuMenName"]);
                                deptnode.isparent = "1";
                                
                                list.Add(deptnode);
    
                                //遍历员工
                                DataTable emp = EDU.DBUtility.DbHelperSQL.GetDataTable("select userId_I,firstName_N from Users  where orgId_I='" + Convert.ToString(row["orgId_I"]) + "' and departId_I='" + Convert.ToString(deptRow["ID"]) + "'");
                                foreach (DataRow empRow in emp.Rows)
                                {
                                    TreeNode empnode = new TreeNode();
                                    empnode.id = Convert.ToString(empRow["userId_I"]);
                                    empnode.pid = Convert.ToString(deptRow["ID"]);
                                    empnode.text = Convert.ToString(empRow["firstName_N"]);
                                    empnode.isparent = "2";
                                    
                                    list.Add(empnode);
                                }
                            }
                        }
    
                        string strJson = LitJson.JsonMapper.ToJson(list);
                        
                        context.Response.ContentType = "text/plain";
                        context.Response.Write(strJson);
                        context.Response.End();
                    }
    
                    break;
    public class TreeNode
    {
        public string id { get; set; }
        public string pid { get; set; }
        public string text { get; set; }
        public string isparent { get;set;}
    }
  • 相关阅读:
    Ubuntu18.04安装NAVIDIA驱动
    ubuntu 设置root用户密码并实现root用户登录
    配置ubuntu允许远程SSH连接
    Centos7安装yum命令
    NVDIA往期在线研讨会地址 论坛提问地址
    二进制安装单master节点测试环境k8s集群
    kubeadm初始化k8s-延长证书过期时间
    kubeadm初始化k8s-删除控制节点-重新把控制节点加入集群步骤
    kubeadm安装的多master节点的k8s高可用集群
    二进制安装多master节点的k8s集群
  • 原文地址:https://www.cnblogs.com/kennyliu/p/4073837.html
Copyright © 2020-2023  润新知