博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
easyui combotree的使用
阅读量:6802 次
发布时间: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

你可能感兴趣的文章
how to send mail from 3rd
查看>>
mappingResources、mappingLocations、mappingDirectoryLocations、mappingJarLocations
查看>>
AJAX 传递jison数组 ;前端循环辅助数组 -----解决方案
查看>>
关于磁盘相关知识
查看>>
Mozilla推出HTML/CSS在线交互式学习网站Thimble
查看>>
关于ppp认证
查看>>
彻底禁用SilentDetection.aspx,极速登录
查看>>
为了忘却的纪念,我的天龙游戏生涯
查看>>
12294错误事件的处理--利用审核日志查找病毒来源
查看>>
第25讲: Scala中柯里化实战详解
查看>>
81.LAMP,PHP5和PHP7安装
查看>>
linux服务(一)LAMP编译安装
查看>>
一次RPC调用时间都去哪儿了
查看>>
linux的rsync工具的常用选项及ssh同步介绍
查看>>
oracle内存体系(二)
查看>>
ReflectASM的使用
查看>>
智能家居监控移动手机组态现实生活中的应用
查看>>
笔试题、面试题
查看>>
shell 数组
查看>>
Linux操作系统的安装
查看>>