Easyui tree

js

 function showCategory(){ 
 var id=0; 
 $('#tt').tree({
  	checkbox: true, 
  	cascadeCheck:false, url: '/comp/companyMenu', 
  	onBeforeExpand:function(node,param){
  	$('#tt').tree('options').url = "/comp/companyMenu?id=" + node.id; 
  },onClick: function(node){ 
  	var check=node.checked; if(check==false){//复选框没有选中时单击选中 
  		$("#tt").tree("check", node.target);
   	}else{//选中时就取消选中 
  		$("#tt").tree("uncheck", node.target); 
   	} 
 },onSelect: function (node) {//选择项复选框选中
    	var checkedNode = $('#tt').tree('getChecked');
     	if (checkedNode != null && checkedNode.length > 0) {
       	$.each(checkedNode, function (index, value) { 
      	$('#tt').tree('uncheck', value.target);
   }) } } }); }

controller

public void companyMenu(){ 
	Integer id=getParaToInt("id");
 	if(id==null) id=0; 
 	renderJson(TreeNodeUtil.getNodesById(id)); 
 }

service

  public static List<Record> getNodesById(int id){
        Company dao=new Company();
        String sql="select id id,name text,fatherid pid from company where fatherId="+id;
        List<Record> menu=Db.find(sql);
        if(menu!=null){ for (int i = 0; i < menu.size(); i++) {
            String sql1="select id id,name text,fatherid pid from company where fatherId="+menu.get(i).getInt("id");
            List<Record> menu1=Db.find(sql1);
            if(menu1.size()>0){ menu.get(i).set("state","closed");
            }else{ menu.get(i).set("state","true");
            }
        }
        }
        return menu; 
    }

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值