欧美大屁股bbbbxxxx,狼人大香伊蕉国产www亚洲,男ji大巴进入女人的视频小说,男人把ji大巴放进女人免费视频,免费情侣作爱视频

歡迎來到入門教程網(wǎng)!

C#教程

當前位置:主頁 > 軟件編程 > C#教程 >

C#使用Jquery zTree實現(xiàn)樹狀結(jié)構(gòu)顯示 異步數(shù)據(jù)加載

來源:本站原創(chuàng)|時間:2020-01-10|欄目:C#教程|點擊: 次

C#使用Jquery zTree實現(xiàn)樹狀結(jié)構(gòu)顯示_異步數(shù)據(jù)加載

JQuery-Ztree下載地址:https://github.com/zTree/zTree_v3

JQuery-Ztree數(shù)結(jié)構(gòu)演示頁面:  http://www.treejs.cn/v3/demo.php#_101

關(guān)于zTree的詳細解釋請看演示頁面,還有zTree幫助Demo。 

下面簡要講解下本人用到的其中一個實例(直接上關(guān)鍵代碼了):

異步加載節(jié)點數(shù)據(jù): 

A-前臺:

<link href="zTree_v3-master/css/zTreeStyle/zTreeStyle.css" rel="stylesheet" />
 <script src="zTree_v3-master/js/jquery.ztree.core.js" type="text/javascript"></script>
 <script language="JavaScript" type="text/javascript">
 var setting = {
  async: {
   enable: true,
   url: "../Handler/ShoppingHandler.ashx", //請求的一般處理程序
   autoParam: ["id"],       //自帶參數(shù)id--來自于節(jié)點id
   otherParam: { "type": "GetUserLevelList" }, //其他參數(shù)自定義
   dataFilter: filter, //數(shù)據(jù)過濾
   type: "post" //請求方式
  }
 };

 function filter(treeId, parentNode, childNodes) {
  if (!childNodes) return null;
  for (var i = 0, l = childNodes.length; i < l; i++) {
   childNodes[i].name = childNodes[i].name.replace(/\.n/g, '.');
  }
  return childNodes;
 }

 $(document).ready(function () {
  $.fn.zTree.init($("#treeDemo"), setting); //渲染樹結(jié)構(gòu)
 });
 </script>
<div class="zTreeDemoBackground left">
  <ul id="treeDemo" class="ztree"></ul>
</div>

B后臺:

using MobileBusiness.Common.Data;
using MobileBusiness.Library.Passport;
using MobileBusiness.Shopping.Data;
using MobileBusiness.Shopping.Data.Common;
using MobileBusiness.Shopping.Data.Entity;
using MobileBusiness.Web.Library.Script;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using ShoppingData = MobileBusiness.Shopping.Data.Entity;

namespace MobileBusiness.Shopping.BusinessManage.Handler
{
 /// <summary>
 /// Shopping 的摘要說明
 /// </summary>
 public class ShoppingHandler : IHttpHandler
 {
  //當前登錄用戶信息
  WeChatUser weChatUser = WeChatIdentity.CurrentUser;

  public void ProcessRequest(HttpContext context)
  {
   string result = "";
   if (context.Request["type"] != null)
   {
    string requestType = context.Request["type"];

    try
    {
     switch (requestType)
     {
      //獲取用戶信息等級列表
      case "GetUserLevelList":
       result = this.GetUserLevelList(context); break;
      default:
       break;
     }
    }
    catch (Exception ex)
    {
     result = ex.Message;
    }
   }

   context.Response.ContentType = "text/html";
   context.Response.Write(result);
   context.Response.End();
  }

  private string GetUserLevelList(HttpContext context)
  {
   string parentUserPhone = context.Request["id"];
   return GetUserCollByPhone(parentUserPhone);
  }
  private string GetUserCollByPhone(string phone)
  {
   //編碼,父編碼,名稱,是否打開,打開圖片,關(guān)閉圖片
   //{ id:1, pId:0, name:"展開、折疊 自定義圖標不同", open:true, iconOpen:"../../../css/zTreeStyle/img/diy/1_open.png", iconClose:"../../../css/zTreeStyle/img/diy/1_close.png"},
   //編碼,父編碼,名稱,是否打開,顯示圖片
   //{ id: 11, pId: 1, name: "葉子節(jié)點1", icon: "../../../css/zTreeStyle/img/diy/2.png"},
   List<object> result = new List<object>();

   ShoppingData.UserInfoCollection userColl = ShoppingData.UserInfoAdapter.Instance.LoadByParentUserPhone(phone);
   userColl.ForEach(user =>
   {
    result.Add(new
    {
     id = user.Phone,
     pid = phone,
     name = user.UserName,
     isParent = ShoppingData.UserInfoAdapter.Instance.LoadByParentUserPhone(user.Phone).Count > 0 ? true : false
    });
   });
   return JsonConvert.SerializeObject(result);
  }
  public bool IsReusable
  {
   get
   {
    return false;
   }
  }
 }
}

以上就是本文的全部內(nèi)容,希望對大家的學(xué)習有所幫助,也希望大家多多支持我們。

上一篇:淺析C#中結(jié)構(gòu)與類的區(qū)別

欄    目:C#教程

下一篇:C# 6.0 的知識梳理

本文標題:C#使用Jquery zTree實現(xiàn)樹狀結(jié)構(gòu)顯示 異步數(shù)據(jù)加載

本文地址:http://mengdiqiu.com.cn/a1/C_jiaocheng/6065.html

網(wǎng)頁制作CMS教程網(wǎng)絡(luò)編程軟件編程腳本語言數(shù)據(jù)庫服務(wù)器

如果侵犯了您的權(quán)利,請與我們聯(lián)系,我們將在24小時內(nèi)進行處理、任何非本站因素導(dǎo)致的法律后果,本站均不負任何責任。

聯(lián)系QQ:835971066 | 郵箱:835971066#qq.com(#換成@)

Copyright © 2002-2020 腳本教程網(wǎng) 版權(quán)所有