码迷,mamicode.com
首页 > 其他好文 > 详细

下拉列表树形结构

时间:2017-07-18 15:26:38      阅读:177      评论:0      收藏:0      [点我收藏+]

标签:ams   getname   void   width   roo   return   value   option   code   

上级菜单<select id="cc" class="easyui-combotree" style="width:223px;" name=‘parentid‘
        data-options="url:‘<%=request.getContextPath()%>/sysMenu/combolist‘">
    @RequestMapping("/combolist")
    public void combolist(HttpServletRequest request,HttpServletResponse response){
            

        List<SysMenu> list = null;
        Map<String,Object> params = new HashMap<String,Object>();
        HashMap<String,Object> dataMap = new HashMap<String,Object>();
        
        //查询列表
        list = this.sysMenuService.list(params);
        
        List menuList = new ArrayList<Map>();
        //根菜单
        HashMap<String,Object> menuRootMap = new HashMap<>();
        
        ArrayList<Map<String,Object>> modalArray = new ArrayList<Map<String,Object>>();
        for(SysMenu menuParent : list){
            
            if(menuParent.getParentid() == null || menuParent.getParentid() == 0){
                menuRootMap.put("id", menuParent.getId());
                menuRootMap.put("text", menuParent.getName());
            }
            
            
            //二级模块
            if(menuParent.getParentid() == 13){
                HashMap<String,Object> menuParentMap = new HashMap<String,Object>();
                ArrayList<Map<String,Object>> childrenList = new ArrayList<Map<String,Object>>() ;
                menuParentMap.put("id", menuParent.getId());
                menuParentMap.put("text", menuParent.getName());
                
                //菜单
                for(SysMenu menuChildren : list){
                    
                    if(menuChildren.getParentid().intValue() == menuParent.getId().intValue()){
                        HashMap<String,Object> menuChildrenMap = new HashMap<>();
                        menuChildrenMap.put("id", menuChildren.getId());
                        menuChildrenMap.put("text", menuChildren.getName());
                        
                        childrenList.add(menuChildrenMap);
                    }
                }
                menuParentMap.put("children", childrenList);
                modalArray.add(menuParentMap);
            }
        }
        
        menuRootMap.put("children", modalArray);
        
        menuList.add(menuRootMap);
        
        //HashMap<String,Object> messageMap = new HashMap<String,Object>();
        //messageMap.put("rows", list);
        
        //this.out(response, messageMap);
        this.webOut(response, menuList);
        return;
    }

 

下拉列表树形结构

标签:ams   getname   void   width   roo   return   value   option   code   

原文地址:http://www.cnblogs.com/cuijinlong/p/7200303.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!