js (jQuery)分组数据
function getobjArr (data) {
var result = [];
data.HELMET.system = '系统分类'
// console.log(data)
$.each(data.HELMET, function (index_h, elem_h) {
var h = {
id: index_h,
name: elem_h,
Projects: []
}
$(data.sonProjects).each(function (index_p, elem_p) {
elem_p.AppCategorys = [];
if (elem_p.sysCategory == 1) {
if (index_h == 'system') {
h.Projects.push(elem_p);
}
} else {
if (index_h != 'system') {
$(data.sonProjectAppCategorys).each(function (index_c, elem_c) {
elem_c.childsList = [];
if (elem_c.childs == '0') {
if (elem_c.helmet == index_h && elem_c.spId == elem_p.spId && elem_c.pId == 0) {
elem_p.AppCategorys.push(elem_c); // console.log(elem_p.AppCategorys)
}
} else {
$(elem_c.childs.split(',')).each(function (index_ch, elem_ch) {
var parent = $$.getobj(data.sonProjectAppCategorys, 'spacId', elem_ch);
if (parent) {
parent.childsList = [];
if (parent.childs == '0') {
elem_c.childsList.push($.extend(true, {}, parent));
} else {
$(parent.childs.split(',')).each(function (index_cht, elem_cht) {
var child = $$.getobj(data.sonProjectAppCategorys, 'spacId', elem_cht);
parent.childsList.push($.extend(true, {}, child));
});
elem_c.childsList.push($.extend(true, {}, parent));
}
}
});
if (elem_c.helmet == index_h && elem_c.spId == elem_p.spId && elem_c.pId == 0) { elem_p.AppCategorys.push(elem_c); }
}
}) h.Projects.push(elem_p);
}
}
})
result.push($.extend(true, {}, h)); // 深复制
})
// console.log(result)
return result;
};
js (jQuery)分组数据的更多相关文章
- js,jquery,css,html5特效
包含js,jquery,css,html5特效,源代码 本文地址:http://www.cnblogs.com/roucheng/p/texiao.html 2017新年快乐特效 jQuery最新最全 ...
- Js/Jquery获取iframe中的元素
转载: Js/Jquery获取iframe中的元素 - - ITeye技术网站http://java-my-life.iteye.com/blog/1275205 在web开发中,经常会用到ifram ...
- js/jquery/html前端开发常用到代码片段
1.IE条件注释 条件注释简介 IE中的条件注释(Conditional comments)对IE的版本和IE非IE有优秀的区分能力,是WEB设计中常用的hack方法.条件注释只能用于IE5以上,IE ...
- js jquery 页面加载初始化方法
js jquery 页面加载初始化方法 一.js页面加载初始化方法 // 1.在body里面写初始化方法. <body onload='init()'> </body> < ...
- js jquery 选择器总结
js jquery 选择器总结 一.原始JS选择器. id选择器:document.getElementById("test"); name选择器:document.getElem ...
- [JS]jQuery,javascript获得网页的高度和宽度
[JS]jQuery,javascript获得网页的高度和宽度网页可见区域宽: document.body.clientWidth 网页可见区域高: document.body.clientHeigh ...
- spring访问静态资源出错,No mapping found for HTTP request with URI xxx/resources/js/jquery.min.js...
问题:spring访问静态资源出错,No mapping found for HTTP request with URI xxx/resources/js/jquery.min.js... web.x ...
- js jquery中 的数据类型
任何一门语言, buguan 是动态的, 还是像C语言的, 都有严格的 类型 "概念的", 这个是由于 编译器和解释器要求的, 需要的. 所以在是使用像 js, jquey ,ph ...
- paip.提升效率--数据绑定到table原理和流程Angular js jquery实现
paip.提升效率--数据绑定到table原理和流程Angular js jquery实现 html #--keyword 1 #---原理和流程 1 #----jq实现的代码 1 #-----An ...
- JS Jquery去除数组重复元素
js jquery去除数组中的重复元素 第一种:$.unique() 第二种: for(var i = 0,len = totalArray_line.length;i < len;i++) { ...
随机推荐
- django项目微博第三方登录
此处咱们用到的是 social_django,所以要把此应用注册到配置文件中, INSTALLED_APPS = [ 'django.contrib.admin', 'django.contrib.a ...
- Git使用详细教程(6):git mv重命名文件
与使用git rm类似,Git还提供了重命名文件的命令git mv,我们可以通过该命令重命名文件. 如下图,git mv包含了以下动作
- ruby-操作mysql
ruby操作mysql数据库 以centos7.2为实验环境 Table of Contents 使用DBI访问Mysql 使用Mysql2访问Mysql DBI 安装DBI驱动 很多同学在公司是没有 ...
- leetcode69 X的平方根的几种解法
第一种自然就是调APi啦(手动滑稽) public int mySqrt(int x) { return (int)Math.sqrt(x); } 时间是52 ms,还超过了1/5的人呢 第二种 二分 ...
- hibernate框架(1)---Hibernate增删改查
Hibernate增删改查 1.首先我们要知道什么是Hibernate Hibernate是一个轻量级的ORMapping对象.主要用来实现Java和数据库表之间的映射,除此之外还提供数据查询和数据获 ...
- spring cloud+.net core搭建微服务架构:服务注册(一)
背景 公司去年开始使用dotnet core开发项目.公司的总体架构采用的是微服务,那时候由于对微服务的理解并不是太深,加上各种组件的不成熟,只是把项目的各个功能通过业务层面拆分,然后通过nginx代 ...
- mysql 架构篇系列 3 复制运行状态监控与选项参数说明
一. 概述 在上一篇中,搭建了一主一从的复制架构,这篇通过一些诊断方法来了解复制的运行状态和一些选项参数说明.上次mysql主从服务关机,今天在打开mysql服务,出现了错误信息. 1.首先 启动主从 ...
- mysql 开发进阶篇系列 51 权限与安全(权限表user,db详细介绍 )
一.概述 mysql 的权限系统主要用来对连接到数据库的用户进行权限验证,以此来判断此用户是否属于合法用户,以及合法用户给予的相应数据库权限.下面将介绍权限系统的工作原理,以及将要熟练掌握账号的管理和 ...
- Java代码更改shape和selector文件的颜色值
Android里面经常会使用shape或者selector来定制一些View的背景.那么如果想要动态更改shape或者seletor文件中的颜色值,该怎么处理呢? 一.Java代码更改shape的颜色 ...
- [Jenkins]IOS构建机配置记录
------------------- 如需转载,请注明出处 ------------------- 随着业务量和开发人员的递增,IOS构建每天都会排队,影响研发效率.随购买了新的垃圾桶,进行配置. ...