C#ʹÓÃJquery zTreeʵÏÖÊ÷×´½á¹¹ÏÔʾ Òì²½Êý¾Ý¼ÓÔØ。本站提示廣大學習愛好者:(C#ʹÓÃJquery zTreeʵÏÖÊ÷×´½á¹¹ÏÔʾ Òì²½Êý¾Ý¼ÓÔØ)文章只能為提供參考,不一定能成為您想要的結果。以下是C#ʹÓÃJquery zTreeʵÏÖÊ÷×´½á¹¹ÏÔʾ Òì²½Êý¾Ý¼ÓÔØ正文
C#ʹÓÃJquery zTreeʵÏÖÊ÷×´½á¹¹ÏÔʾ_Òì²½Êý¾Ý¼ÓÔØ
JQuery-ZtreeÏÂÔصØÖ·£ºhttps://github.com/zTree/zTree_v3
JQuery-ZtreeÊý½á¹¹ÑÝʾҳÃ棺 http://www.treejs.cn/v3/demo.php#_101
¹ØÓÚzTreeµÄÏêϸ½âÊÍÇë¿´ÑÝʾҳÃ棬»¹ÓÐzTree°ïÖúDemo¡£
ÏÂÃæ¼òÒª½²½âϱ¾ÈËÓõ½µÄÆäÖÐÒ»¸öʵÀý£¨Ö±½ÓÉϹؼü´úÂëÁË£©£º
Òì²½¼ÓÔؽڵãÊý¾Ý£º
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"], //×Ô´ø²ÎÊýid--À´×ÔÓÚ½Úµãid otherParam: { "type": "GetUserLevelList" }, //ÆäËû²ÎÊý×Ô¶¨Òå dataFilter: filter, //Êý¾Ý¹ýÂË 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); //äÖȾÊ÷½á¹¹ }); </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) { //±àÂ룬¸¸±àÂ룬Ãû³Æ£¬ÊÇ·ñ´ò¿ª£¬´ò¿ªÍ¼Æ¬£¬¹Ø±ÕͼƬ //{ 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: "Ò¶×Ó½Úµã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; } } } }
ÒÔÉϾÍÊDZ¾ÎĵÄÈ«²¿ÄÚÈÝ£¬Ï£Íû¶Ô´ó¼ÒµÄѧϰÓÐËù°ïÖú£¬Ò²Ï£Íû´ó¼Ò¶à¶àÖ§³Ö½Å±¾Ö®¼Ò¡£