EasyUI之生成动态异步菜单栏

@ResponseBody

public List

getNode(Integer id){

Menu menu = new Menu();

if(id !=null && id > 0){

menu.setParentId(id);

}else{

menu.setParentId(0);

}

return menuService.query(menu);

}

然后在控制器中具体处理请求

public List

query(Menu menu) {

MenuExample example = new MenuExample();

MenuExample.Criteria criteria = example.createCriteria();

if(menu!=null){

if(menu.getParentId()!=null ){

// 根据父菜单编号查询

criteria.andParentIdEqualTo(menu.getParentId());

}else{

criteria.andParentIdEqualTo(0);

}

}

return menuMapper.selectByExample(example);

}

4.页面js代码实现


home界面的主要代码如下:

style="height: 100px;background: url(img/logo.png) no-repeat 0% 50%; ">

百战程序员 |

<shiro:principal property=“username”></shiro:principal> |

安全退出

style=“width: 180px;”>

    style=“padding: 0px; background: #eee;”>

    欢迎光临

    加载导航菜单的核心代码:

    // 加载菜单数据 state:closed是关键

    $(function(){

    // 动态添加菜单

    $(“#tt”).tree({

    url: “/sys/menu/getNode”,

    onClick: function(node){

    if(node.url != null && node.url != ‘’ ){

    // 打开一个新的窗口

    goTabs(node.url+“/go”,node.text);

    }

    }

    });

    });

    // 点击子菜单开的一个新窗口的代码

    function goTabs(path,title){

    // 动态添加一个标签页

    var isSelect = $(“#tabs”).tabs(‘exists’, title);

    // 添加一个新的标签页面板(tab panel)

    if(isSelect){

    $(“#tabs”).tabs(‘select’, title);

    return;

    }else{

    $(‘#tabs’).tabs(‘add’,{

    title:title,

    content:‘’,

    closable:true,

    //刷新按钮

    tools: [{

    iconCls: ‘icon-mini-refresh’,

    handler: function(){

    var currentTab = $(‘#tabs’).tabs(‘getSelected’);

    RefreshTab(currentTab);

    }

    }]

    });

    }

    }

    //刷新当前标签Tabs

    function RefreshTab(currentTab) {

    var url = $(currentTab.panel(‘options’)).attr(‘href’);

    $(‘#tabs’).tabs(‘update’, {

    tab: currentTab,

    评论
    添加红包

    请填写红包祝福语或标题

    红包个数最小为10个

    红包金额最低5元

    当前余额3.43前往充值 >
    需支付:10.00
    成就一亿技术人!
    领取后你会自动成为博主和红包主的粉丝 规则
    hope_wisdom
    发出的红包
    实付
    使用余额支付
    点击重新获取
    扫码支付
    钱包余额 0

    抵扣说明:

    1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
    2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

    余额充值