• easyui- comobo 详细讲解


    具体代码实现

    @{
        ViewBag.Title = "人员查找";
        ViewBag.LeftWidth = "200px";
        ViewBag.MiddleWidth = "200px";
    }
    <html>
    <head>
        <link href="../../../Script/easyui/themes/bootstrap/easyui.css" rel="stylesheet"
            type="text/css" />
        <link href="../../../Script/easyui/themes/icon.css" rel="stylesheet" type="text/css" />
        <link href="../../../Content/themes/base/Common/common.css" rel="stylesheet" type="text/css" />
        <script src="../../../Script/easyui/jquery-1.8.3.min.js" type="text/javascript"></script>
        <script src="../../../Script/Common/json2.js" type="text/javascript"></script>
        <script src="../../../Script/easyui/jquery.easyui.min.js" type="text/javascript"></script>
        <script src="../../../Script/easyui/easyui-lang-zh_CN.js" type="text/javascript"></script>
        <script src="../../../Script/Common/Toolbar.js" type="text/javascript"></script>
        <script src="../../../Script/easyui/plugins/JValidator.js" type="text/javascript"></script>
        <script src="../../../Script/Common/Common.js" type="text/javascript"></script>
    </head>
    <body class="easyui-layout">
        <div region="north" data-options="border:false" style="height: 50px;">
            <select id="Deptree" class="easyui-combotree" style=" 200px;">
            </select>
        </div>
        <script type="text/javascript">
            //页面加载按部门搜索部门树列表
            var MySearchOrg = {
                //加载左侧部门树
                onloadDepTree: function () { //部门树方法
                    $('#Deptree').combotree({
                        multiple: true,
                        checkbox: true,
                        url: '../SearchOrg/GetOrganizationList',
                        onHidePanel: function () {

                            var t = $('#Deptree').combotree('tree'); // get the tree object
                            var n = t.tree('getChecked');  // get selected node
                          

                        }


                    });
                }

            }

            $(function () {

                MySearchOrg.onloadDepTree();

            });


        </script>
    //后台

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Collections;
    using System.Web.Mvc;
    using System.Web;
    using System.Data;
    using GWork.Models;
    using Newtonsoft.Json;
    using GWork.DataAccess;
    using GWork.Business;
    using GWork.IBusiness;
    using SysManager.Models;
    using SysManager.Common.Utilities;
    using Newtonsoft.Json.Converters;
    namespace GWork.Controllers.OpenWindows.SearchEmployee
    {
        public class SearchOrgController : Controller
        {

            private SYS_User userinfo = new SYS_User();
            private SYS_Organization organizationinfo = new SYS_Organization(); //权限表中的组织部门
            private SysManager.IBusiness.IOrganizationBLL organizationibll = SysManager.Business.BusinessFactory.Instance.CreateOrganization();//部门工厂
            private SysManager.IBusiness.IRolesBLL rolesbll = SysManager.Business.BusinessFactory.Instance.CreateRoles();//角色工厂
            private SysManager.IBusiness.IUserBLL userbll = SysManager.Business.BusinessFactory.Instance.CreateUser();//  获取员工用户方法


            public ActionResult SearchOrgList()//搜索试图
            {
                return View();
            }

            #region 获取部门列表树集合
            /// <summary>
            /// 获取部门列表树集合
            /// </summary>
            /// <returns></returns>
            public string GetOrganizationList()
            {

                System.Collections.IList orgainList = organizationibll.GetList();//获取部门方法
                IsoDateTimeConverter timeConverter = new IsoDateTimeConverter();
                timeConverter.DateTimeFormat = "yyyy'-'MM'-'dd' 'HH':'mm':'ss";
                List<SYS_Organization> listtree = SysManager.Common.Utilities.IListHelper.IListToList<SYS_Organization>(orgainList);//将IList 转化成List
                SYS_Organization orgobj = listtree.Find(org => org.ParentId == "0");//构造顶级节点//(数据库中用的是O)
                LEFTTREE lefttree = new LEFTTREE();
                lefttree.ID = orgobj.OrganizationId; //树节点
                lefttree.TEXT = orgobj.FullName;   //公司名称
                lefttree.CHILDREN = new List<LEFTTREE>();  //树子节点
                lefttree.EX1 = orgobj.Category;// (额外条件种类)

                TreeDiGui(lefttree.ID, lefttree, listtree); //递归用法

                return "[" + JsonConvert.SerializeObject(lefttree).Replace("TEXT", "text").Replace("ID", "id").Replace("CHILDREN", "children") + "]";
            }

            #region 查找树的子节点
            /// <summary>
            /// 查找树的子节点
            /// </summary>
            /// <param name="sb"></param>
            /// <param name="ParentId"></param>
            /// <returns></returns>
            public LEFTTREE TreeDiGui(string ParentId, LEFTTREE LEFTTREE, IEnumerable<SYS_Organization> ALLTREE)
            {

                //
                IEnumerable<SYS_Organization> FindTree = ALLTREE.Where(new Func<SYS_Organization, bool>(d => d.ParentId == ParentId));
                foreach (SYS_Organization item in FindTree)
                {
                    LEFTTREE ChildTree = new LEFTTREE();
                    ChildTree.ID = item.OrganizationId;
                    ChildTree.TEXT = item.FullName;
                    ChildTree.CHILDREN = new List<LEFTTREE>();
                    ChildTree.EX1 = item.Category;//种类
                    LEFTTREE.CHILDREN.Add(ChildTree);
                    TreeDiGui(ChildTree.ID, ChildTree, ALLTREE);
                }
                return LEFTTREE;
            }
            #endregion

            #endregion

           

           


        }
    }

  • 相关阅读:
    901Air724UG模块(4G全网通GPRS开发)Air724UG(4G)使用SPI控制CH395Q(以太网模块)实现TCP/IP通信
    02STM32+MN316(NBIOT)基本控制篇(自建MQTT服务器)硬件使用说明
    Docker 清理none镜像 Prune命令
    Leetcode 252. 会议室 253. 会议室II 贪心算法扫描线技巧
    Leetcode 77. 组合(中等)回溯算法
    Leetcode 787. K 站中转内最便宜的航班(中等) 动态规划
    Leetcode 174. 地下城游戏(困难) 动态规划
    Linux arm环境下pip3安装av失败
    Leetcode 134. 加油站(中等) 贪心算法
    Leetcode 698. 划分为k个相等的子集(中等) 回溯算法=集合划分
  • 原文地址:https://www.cnblogs.com/dullbaby/p/3571665.html
Copyright © 2020-2023  润新知