js (jQuery)分组数据
生活随笔
收集整理的這篇文章主要介紹了
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;};
更多專業前端知識,請上 【猿2048】www.mk2048.com
更多專業前端知識,請上 【猿2048】www.mk2048.com
總結
以上是生活随笔為你收集整理的js (jQuery)分组数据的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: angularJS解决数据显示闪一下的问
- 下一篇: js 提取某()特殊字符串长度