91超碰碰碰碰久久久久久综合_超碰av人澡人澡人澡人澡人掠_国产黄大片在线观看画质优化_txt小说免费全本

溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務條款》

怎么用EasyUI Tree+Asp.net實現權限樹或目錄樹導航

發布時間:2021-07-26 14:03:16 來源:億速云 閱讀:106 作者:chen 欄目:開發技術

本篇內容介紹了“怎么用EasyUI Tree+Asp.net實現權限樹或目錄樹導航”的有關知識,在實際案例的操作過程中,不少人都會遇到這樣的困境,接下來就讓小編帶領大家學習一下如何處理這些情況吧!希望大家仔細閱讀,能夠學有所成!

復制代碼 代碼如下:


<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Main.aspx.cs" Inherits="Manage_Main" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>網站后臺通用管理系統,<%=adminname%>,您好!</title>
    <link href="Css/default.css" rel="stylesheet" type="text/css" />
    <!--easyui-->
    <link rel="stylesheet" type="text/css" href="easyui/themes/default/easyui.css" />
    <link rel="stylesheet" type="text/css" href="easyui/themes/default/tree.css" />
    <link rel="stylesheet" type="text/css" href="easyui/themes/icon.css" />
    <script type="text/javascript" src="easyui/jquery-1.8.0.min.js"></script>
    <script type="text/javascript" src="easyui/jquery.easyui.min.js"></script>
    <script type="text/javascript" src='EasyUI/JQLoader.js'> </script>
    <script type="text/javascript" src='EasyUI/outlook.js'> </script>
    <script type="text/javascript">
        $(function () {
            $('#lefttree').tree({
                animate: true,
                checkbox: false,
                url: 'GetTreeDataFromDB.ashx?father=0',
                onClick: function (node) {
                    if (node.attributes != "") {
                        addTab(node.text, node.attributes, node.id);
                    }
                },
                onLoadSuccess: function (node, data) {
                    $('#lefttree').show();
                }
            });

            $('#loginOut').click(function () {
                $.messager.confirm('系統提示', '您確定要退出本次登錄嗎?', function (r) {
                    if (r) {
                        location.href = 'LoginExit.ashx';
                    }
                });
            })
        });
    </script>
    </head>
    <body class="easyui-layout"   scroll="no">
    <form id="form1" runat="server">
      <noscript>
      <div > <img src="images/noscript.gif" alt='抱歉,請開啟腳本支持!' /> </div>
      </noscript>
      <div region="north" split="true" border="false" >
        <div > <span class="head">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span>
          <div  class="head"> <span class="icon icon-quit">&nbsp;</span><a href="#" id="loginOut">安全退出</a> </div>
        </div>
        <span ><img src="images/blocks.gif" width="20" height="20" align="absmiddle" />網站后臺通用管理系統 V1.0</span> </div>
      <div region="south" split="true" >
        <div class="footer"> 網站后臺通用管理系統 <%=adminname%>,您好! 版權所有@2012</div>
      </div>
      <div region="west" hide="true" split="true" title="導航菜單"  id="west">
        <div id="nav" class="easyui-accordion" fit="true" border="false">
          <!--  導航內容 -->
          <div id="lefttree" ></div>
        </div>
      </div>
      <div id="mainPanle" region="center" >
        <div id="tabs" class="easyui-tabs"  fit="true" border="false" >
          <div title="歡迎使用"  > <span >歡迎進入系統</span> </div>
        </div>
      </div>
      <div id="mm" class="easyui-menu" >
        <div id="mm-tabupdate">刷新</div>
        <div class="menu-sep"></div>
        <div id="mm-tabclose">關閉</div>
        <div id="mm-tabcloseall">全部關閉</div>
        <div id="mm-tabcloseother">除此之外全部關閉</div>
        <div class="menu-sep"></div>
        <div id="mm-tabcloseright">當前頁右側全部關閉</div>
        <div id="mm-tabcloseleft">當前頁左側全部關閉</div>
        <div class="menu-sep"></div>
        <div id="mm-exit">退出</div>
      </div>
    </form>
</body>
</html>

復制代碼 代碼如下:


<%@ WebHandler Language="C#" Class="GetTreeDataFromDB" %>

using System;
using System.Web;
using System.Configuration;
using System.Data;
using System.Text;
using System.Collections.Generic;
//add
using System.Web.Script.Serialization;

public class GetTreeDataFromDB : IHttpHandler
{

    public void ProcessRequest(HttpContext context)
    {
        context.Response.ContentType = "text/plain";

        //獲取數據庫中的分類數據
        string fatherid = context.Request.QueryString["father"];
        DataTable dt = createDT();

        string json = GetTreeJsonByTable(dt, "module_id", "module_name","module_url", "module_fatherid", "0");
        context.Response.Write(json);
        context.Response.End();       
    }

    #region 根據DataTable生成EasyUI Tree Json樹結構
    StringBuilder result = new StringBuilder();
    StringBuilder sb = new StringBuilder();   
    /// <summary>
    /// 根據DataTable生成EasyUI Tree Json樹結構
    /// </summary>
    /// <param name="tabel">數據源</param>
    /// <param name="idCol">ID列</param>
    /// <param name="txtCol">Text列</param>
    /// <param name="url">節點Url</param>
    /// <param name="rela">關系字段</param>
    /// <param name="pId">父ID</param>
    private string GetTreeJsonByTable(DataTable tabel, string idCol, string txtCol, string url, string rela, object pId)
    {
        result.Append(sb.ToString());
        sb.Clear();
        if (tabel.Rows.Count > 0)
        {
            sb.Append("[");
            string filer = string.Format("{0}='{1}'", rela, pId);
            DataRow[] rows = tabel.Select(filer);
            if (rows.Length > 0)
            {
                foreach (DataRow row in rows)
                {
                    sb.Append("{\"id\":\"" + row[idCol] + "\",\"text\":\"" + row[txtCol] + "\",\"attributes\":\"" + row[url] + "\",\"state\":\"open\"");
                    if (tabel.Select(string.Format("{0}='{1}'", rela, row[idCol])).Length > 0)
                    {
                        sb.Append(",\"children\":");
                        GetTreeJsonByTable(tabel, idCol, txtCol,url, rela, row[idCol]);
                        result.Append(sb.ToString());
                        sb.Clear();
                    }
                    result.Append(sb.ToString());
                    sb.Clear();
                    sb.Append("},");
                }
                sb = sb.Remove(sb.Length - 1, 1);
            }
            sb.Append("]");
            result.Append(sb.ToString());
            sb.Clear();
        }
        return result.ToString();
    }
    #endregion


    #region 創建數據
    protected static DataTable createDT()
    {
        DataTable dt = new DataTable();
        dt.Columns.Add("module_id");
        dt.Columns.Add("module_name");
        dt.Columns.Add("module_fatherid");
        dt.Columns.Add("module_url");
        dt.Columns.Add("module_order");

        dt.Rows.Add("C1", "全國", "0", "1.aspx", "1");
        dt.Rows.Add("M01", "廣東", "C1", "2.aspx", "1");

        dt.Rows.Add("M0101", "深圳", "M01", "3.aspx", "100");
        dt.Rows.Add("M010101", "南山區", "M0101", "4.aspx", "1000");
        dt.Rows.Add("M010102", "羅湖區", "M0101", "", "1001");
        dt.Rows.Add("M010103", "福田區", "M0101", "", "1002");
        dt.Rows.Add("M010104", "寶安區", "M0101", "", "1003");
        dt.Rows.Add("M010105", "龍崗區", "M0101", "", "1004");

        dt.Rows.Add("M01010301", "上梅林", "M010103", "", "1002001");
        dt.Rows.Add("M01010302", "下梅林", "M010103", "", "1002002");
        dt.Rows.Add("M01010303", "車公廟", "M010103", "", "1002003");
        dt.Rows.Add("M01010304", "竹子林", "M010103", "", "1002004");
        dt.Rows.Add("M01010305", "八卦嶺", "M010103", "", "1002005");
        dt.Rows.Add("M01010306", "華強北", "M010103", "", "1002006");

        dt.Rows.Add("M0102", "廣州", "M01", "", "101");
        dt.Rows.Add("M010201", "越秀區", "M0102", "", "1105");
        dt.Rows.Add("M010202", "海珠區", "M0102", "", "1106");
        dt.Rows.Add("M010203", "天河區", "M0102", "", "1107");
        dt.Rows.Add("M010204", "白云區", "M0102", "", "1108");
        dt.Rows.Add("M010205", "黃埔區", "M0102", "", "1109");
        dt.Rows.Add("M010206", "荔灣區", "M0102", "", "1110");
        dt.Rows.Add("M010207", "羅崗區", "M0102", "", "1111");
        dt.Rows.Add("M010208", "南沙區", "M0102", "", "1112");
        return dt;
    }
    #endregion


    public bool IsReusable
    {
        get
        {
            return false;
        }
    }
}

復制代碼 代碼如下:


    #region 根據DataTable生成EasyUI Tree Json樹結構 
    StringBuilder result = new StringBuilder(); 
    StringBuilder sb = new StringBuilder();     
    /// <summary> 
    /// 根據DataTable生成EasyUI Tree Json樹結構 
    /// </summary> 
    /// <param name="tabel">數據源</param> 
    /// <param name="idCol">ID列</param> 
    /// <param name="txtCol">Text列</param> 
    /// <param name="url">節點Url</param> 
    /// <param name="rela">關系字段</param> 
    /// <param name="pId">父ID</param> 
    private string GetTreeJsonByTable(DataTable tabel, string idCol, string txtCol, string url, string rela, object pId) 
    { 
        result.Append(sb.ToString()); 
        sb.Clear(); 
        if (tabel.Rows.Count > 0) 
        { 
            sb.Append("["); 
            string filer = string.Format("{0}='{1}'", rela, pId); 
            DataRow[] rows = tabel.Select(filer); 
            if (rows.Length > 0) 
            { 
                foreach (DataRow row in rows) 
                { 
                    sb.Append("{\"id\":\"" + row[idCol] + "\",\"text\":\"" + row[txtCol] + "\",\"attributes\":\"" + row[url] + "\""); 
                    if (tabel.Select(string.Format("{0}='{1}'", rela, row[idCol])).Length > 0) 
                    { 
                        //點擊展開
                        sb.Append(",\"state\":\"closed\",\"children\":"); 
                        GetTreeJsonByTable(tabel, idCol, txtCol,url, rela, row[idCol]); 
                        result.Append(sb.ToString()); 
                        sb.Clear(); 
                    } 
                    result.Append(sb.ToString()); 
                    sb.Clear(); 
                    sb.Append("},"); 
                } 
                sb = sb.Remove(sb.Length - 1, 1); 
            } 
            sb.Append("]"); 
            result.Append(sb.ToString()); 
            sb.Clear(); 
        } 
        return result.ToString(); 
    } 
    #endregion  

“怎么用EasyUI Tree+Asp.net實現權限樹或目錄樹導航”的內容就介紹到這里了,感謝大家的閱讀。如果想了解更多行業相關的知識可以關注億速云網站,小編將為大家輸出更多高質量的實用文章!

向AI問一下細節

免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。

AI

五台县| 诸城市| 班戈县| 望江县| 桑植县| 屯昌县| 临朐县| 芮城县| 乐至县| 海阳市| 易门县| 漳州市| 延安市| 富裕县| 永城市| 巴马| 肥西县| 横山县| 伊宁县| 武义县| 仁化县| 普安县| 珠海市| 安福县| 翁牛特旗| 莱芜市| 南京市| 赤峰市| 宜兰县| 陇南市| 阳东县| 赣州市| 剑川县| 涡阳县| 囊谦县| 上思县| 河津市| 邛崃市| 阿拉善盟| 丁青县| 元朗区|