C#使用Jquery zTree实现树状结构显示 异步数据加载

时间:2021-05-20

C#使用Jquery zTree实现树状结构显示_异步数据加载

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

JQuery-Ztree数结构演示页面: http://mon;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; } } }}

以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持。

声明:本页内容来源网络,仅供用户参考;我单位不保证亦不表示资料全面及准确无误,也不保证亦不表示这些资料为最新信息,如因任何原因,本网内容或者用户因倚赖本网内容造成任何损失或损害,我单位将不会负任何法律责任。如涉及版权问题,请提交至online#300.cn邮箱联系删除。

相关文章