easyui 无限级数tree[menulist1 = GetMenuList(sm2,menulist1);]
// 左侧导航加载
function addNav(data) {
$.each(data,function(i, sm1) {
var menulist1 = "<ul id='tt1' class='easyui-tree' animate='true' dnd='true'>";
$.each(sm1.menus, function(i, sm2) {
menulist1 = getSelUrl(sm2,menulist1);
menulist1 = GetMenuList(sm2,menulist1);
menulist1 += "</li>";
});
//console.log("------------end 2级UL-------------");
menulist1 += "</ul>";
//console.log(menulist1);
$('#wnav').accordion('add', {title : sm1.menuname,content : menulist1,iconCls : 'icon ' + sm1.icon});
});
var pp = $('#wnav').accordion('panels');
if (pp.length == 0)
return;
var t = pp[0].panel('options').title;
$('#wnav').accordion('select', t);
}
/**
* N级菜单
* @param data
* @param menulist1
* @returns menulist1
*/
function GetMenuList(data, menulist1) {
console.log(menulist1);
if(data.menus.length>0){
menulist1 += "<ul>";
$.each(data.menus, function(i, sm5) {
menulist1 = getSelUrl(sm5,menulist1);
menulist1 = GetMenuList(sm5,menulist1);
menulist1 += "</li>";
});
menulist1 += "</ul>";
}
return menulist1;
}
------------------------
/**
* url select
* @param obj
* @param menulist1
* @returns menulist1
*/
function getSelUrl(obj,menulist1){
if(obj.url!=null && obj.menus.length==0){
menulist1 += "<li><a ref='"+obj.menuid+"' href='#' rel='"+obj.url+"'> <span class='nav'>"+obj.menuname+"</span></a>";
}else{
menulist1 += "<li> <span class='nav'>"+obj.menuname+"</span>";
}
return menulist1;
}
----------------------------------------------
// 左侧导航加载
function addNav(data) {
$.each(data,function(i, sm1) {
var menulist1 = "<ul id='tt1' class='easyui-tree' animate='true' dnd='true'>";
$.each(sm1.menus, function(i, sm2) {
if(sm2.url!=null && sm2.menus.length==0){
menulist1 += "<li><a ref='"+sm2.menuid+"' href='#' rel='"+sm2.url+"'><span class='nav'>"+sm2.menuname+"</span></a>";
}else{
menulist1 += "<li> <span class='nav'>"+sm2.menuname+"</span>";
}
if(sm2.menus.length>0){
menulist1 += "<ul>";
$.each(sm2.menus, function(i, sm3) {
if(sm3.url!=null && sm3.menus.length==0){
menulist1 += "<li><a ref='"+sm3.menuid+"' href='#' rel='"+sm3.url+"'> <span class='nav'>"+sm3.menuname+"</span></a>";
}else{
menulist1 += "<li> <span class='nav'>"+sm3.menuname+"</span>";
}
if(sm3.menus.length>0){
menulist1 += "<ul>";
$.each(sm3.menus, function(i, sm4) {
if(sm4.url!=null && sm4.menus.length==0){
menulist1 += "<li><a ref='"+sm4.menuid+"' href='#' rel='"+sm4.url+"'> <span class='nav'>"+sm4.menuname+"</span></a>";
}else{
menulist1 += "<li> <span class='nav'>"+sm4.menuname+"</span>";
}
if(sm4.menus.length>0){
menulist1 += "<ul>";
$.each(sm4.menus, function(i, sm5) {
if(sm5.url!=null && sm5.menus.length==0){
menulist1 += "<li><a ref='"+sm5.menuid+"' href='#' rel='"+sm5.url+"'> <span class='nav'>"+sm5.menuname+"</span></a>";
}else{
menulist1 += "<li> <span class='nav'>"+sm5.menuname+"</span>";
}
menulist1 += "</li>";
});
menulist1 += "</ul>";
}
menulist1 += "</li>";
});
menulist1 += "</ul>";
}
menulist1 += "</li>";
});
menulist1 += "</ul>";
}
menulist1 += "</li>";
});
//console.log("------------end 2级UL-------------");
menulist1 += "</ul>";
//console.log(menulist1);
$('#wnav').accordion('add', {title : sm1.menuname,content : menulist1,iconCls : 'icon ' + sm1.icon});
});
var pp = $('#wnav').accordion('panels');
if (pp.length == 0)
return;
var t = pp[0].panel('options').title;
$('#wnav').accordion('select', t);
}