zoukankan      html  css  js  c++  java
  • tree的使用

    //html
    <ul id="tree"></ul>

     js

     function initTree() {
            $('#tree').tree({
                url: '/OnlineMonitoring/ashx/departMgr.ashx?type=tree'
                     
            });
    
        }
    

     后台

      根据父id返回当前子节点就好了。(父id为0时返回根节点)

    json示例

         [
        {
            "id": "2",
            "text": "监事会",
            "state": "closed"
        },
        {
            "id": "4259045978553",
            "text": "2",
            "state": "open"
        },
        {
            "id": "4259055249969",
            "text": "a",
            "state": "open"
        }
    ]

    id:node的id

    text:节点名称

    state:closed或open(closed说明有子项)

    贴上一个sqlserver procedure:

      

     create procedure [dbo].[Tree]
        @pid varchar(30)
     as
     begin
        select 
         a.department_id as [id],
         a.department_name as [text],
         case
         when
         (select COUNT(department_id) from dbo.department_info as b where b.department_parent_id=a.department_id)>0
         then 'closed' else 'open'
         end as [state]
         from dbo.department_info as a where a.department_parent_id=@pid;
     end

    根据pid返回树(pid为0时返回根节点)

      依赖:

             <link href="../Scripts/easyui/themes/default/easyui.css" rel="stylesheet" />
              <link href="../Scripts/easyui/themes/icon.css" rel="stylesheet" />
              <link href="../Scripts/easyui/demo/demo.css" rel="stylesheet" />
              <script type="text/javascript" src="../Scripts/easyui/jquery.min.js"></script>
                       <script type="text/javascript" src="../Scripts/easyui/jquery.easyui.min.js"></script>
                <script type="text/javascript" src="../Scripts/easyui/locale/easyui-lang-zh_CN.js"></script>

  • 相关阅读:
    [笔记] 深入java虚拟机 类型的生命周期
    xml笔记
    Python笔记
    Effective C++ 笔记(2)
    [笔记] 深入java虚拟机 连接模型
    javascript对象成员访问权限
    [笔记] 深入java虚拟机 java class文件(2)
    STL笔记(3) Effective STL
    STL笔记(1)容器
    [IOS笔记] objecttivec基础知识
  • 原文地址:https://www.cnblogs.com/gaocong/p/5832766.html
Copyright © 2011-2022 走看看