博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
easyui combotree的使用
阅读量:6804 次
发布时间:2019-06-26

本文共 4399 字,大约阅读时间需要 14 分钟。

前台HTML:

统计年份: 统计部门:
检测项目: 统计
View Code

前台JS:

//部门树$("#dept").combotree({    editable: false,    url: '@Url.Content("~/DetReport/DetReportManage/GetDeptTree")',    onSelect: function (node) {        //加载检测项目        $("#testItem").combotree({            editable: false,            url: '@Url.Content("~/DetReport/YSLReport/GetTestItemTree?deptCode=")' + node.id,            onSelect: function (node) {                //显示全路径                var parent = node;                var tree = $('#testItem').combotree('tree');                var path = new Array();                do {                    path.unshift(parent.text);                    var parent = tree.tree('getParent', parent.target);                } while (parent);                var pathStr = '';                for (var i = 0; i < path.length; i++) {                    pathStr += path[i];                    if (i < path.length - 1) {                        pathStr += ' - ';                    }                }                setTimeout(function () {                    $('input[name="testItem"]').prev().val(pathStr);                }, 100);            }        });    }});
View Code

后台代码1:

/// /// 获取部门树/// public JsonResult GetDeptTree(){    List list = new List();    List
deptListAll = m_DeptDal.GetDeptListAll(); foreach (SYS_DEPT dept0 in deptListAll.FindAll(a => string.IsNullOrWhiteSpace(a.PDEPTCODE))) { var obj0 = new { id = dept0.DEPTCODE, text = dept0.DEPTNAME, children = new List
() }; foreach (SYS_DEPT dept1 in deptListAll.FindAll(a => a.PDEPTCODE == dept0.DEPTCODE)) { var obj1 = new { id = dept1.DEPTCODE, text = dept1.DEPTNAME, children = new List() }; foreach (SYS_DEPT dept2 in deptListAll.FindAll(a => a.PDEPTCODE == dept1.DEPTCODE)) { var obj2 = new { id = dept2.DEPTCODE, text = dept2.DEPTNAME, children = new List() }; foreach (SYS_DEPT dept3 in deptListAll.FindAll(a => a.PDEPTCODE == dept2.DEPTCODE)) { var obj3 = new { id = dept3.DEPTCODE, text = dept3.DEPTNAME, children = new List() }; obj2.children.Add(obj3); } obj1.children.Add(obj2); } obj0.children.Add(obj1); } list.Add(obj0); } return Json(list, JsonRequestBehavior.AllowGet);}
View Code

后台代码2:

/// /// 获取检测项目树(统计用)/// public JsonResult GetTestItemTree(string deptCode){    List list = new List();    List
deptListAll = m_DeptDal.GetDeptListAll(); List
itemListAll = m_DetectionItemsDAL.GetDetectionItemsListAll(); List
specialtyListAll = m_SpecialtyDAL.GetSpecialtyListAll(); List
deptList = deptListAll.FindAll(a => a.DEPTCODE.IndexOf(deptCode) == 0); if (deptList.Count > 0) { foreach (SPECIALTY specialty in specialtyListAll.FindAll(a => deptList.Exists(b => b.DEPTCODE == a.DEPTCODE))) { var specialtyObj = new { id = specialty.SPECIALTYID, text = specialty.SPECIALTYNAME, leaf = false, type = 1, //1专业2样品名称3检测项目 children = new List
() }; foreach (DETECTIONITEMS items in itemListAll.FindAll(a => a.SPECIALTYID == specialty.SPECIALTYID && a.PID == 0)) { List
subItemsList = itemListAll.FindAll(a => a.PID == items.DETITEMID); var itemsObj = new { id = items.DETITEMID, text = items.ITEMNAME, leaf = subItemsList.Count > 0 ? false : true, //只能选择leaf为true的节点 type = 2, //1专业2样品名称3检测项目 children = new List
() }; foreach (DETECTIONITEMS subItems in subItemsList) { var subItemsObj = new { id = subItems.DETITEMID, text = subItems.ITEMNAME, leaf = true, //只能选择leaf为true的节点 type = 3, //1专业2样品名称3检测项目 children = new List() }; itemsObj.children.Add(subItemsObj); } specialtyObj.children.Add(itemsObj); } list.Add(specialtyObj); } } return Json(list, JsonRequestBehavior.AllowGet);}
View Code

示意图:

 

转载于:https://www.cnblogs.com/s0611163/p/6007106.html

你可能感兴趣的文章
卡尔曼滤波器原理之基本思想(一)
查看>>
微信 {"errcode":40029,"errmsg":"invalid code, hints: [ req_id: Cf.y.a0389s108 ]"}
查看>>
appserv安装
查看>>
SQL Server 动态行转列(参数化表名、分组列、行转列字段、字段值)
查看>>
2018-2019-2 20165325 《网络对抗技术》 Exp5:MSF基础应用
查看>>
Java基础扫盲系列(二)—— Java中BigDecimal和浮点类型
查看>>
如何在直播中解决黑屏、花屏、闪屏问题 | 直播疑难杂症排查
查看>>
js获取浏览器高度和宽度值(多浏览器)
查看>>
Deep learning:十六(deep networks)
查看>>
▲移动web前端开发
查看>>
LeetCode: Palindrome Partition
查看>>
推荐使用C++ 11
查看>>
C#中的接口
查看>>
Vue 实例暴露了一些有用的实例属性与方法。这些属性与方法都有前缀 $,以便与代理的 data 属性区分...
查看>>
从零开始做SSH项目(二)
查看>>
spring ioc aop 理解
查看>>
python学习资料
查看>>
JQuery与js具体使用的区别(不全,初学)
查看>>
Hyper-V快速导入虚拟机的两个注意事项
查看>>
【转】getopt模块,实现获取命令行参数
查看>>