easy ui Tree 的使用

MQ发送接受消息,获取后台返回的数据,然后自己进行封装成tree里面所需要的json格式!里面主要用到异步加载tree的方法!

$("#tree").tree({  
        data:jsonstring,
        //显示加减号  
        lines:true,  
        animate:true,  
        //展开前   
        onBeforeExpand:function(node){  
                 // 异步加载的地址并传递参数   
                 // $("#tree").tree("options").url ="?"+node.id;   
                 //alert(node.parentpath+ "/" + node.text);return;
                 var treeObjFinall = eval("(" + treeString + ")");
                // treeObjFinall.subdir = new Object()
                 treeObjFinall.subdir.currpath = node.parentpath+ "/" + node.text;
                 var treeStringFinall = JSON.stringify(treeObjFinall);
                 //alert(treeStringFinall);return;
                 var treeChinArray = new Array();
                 $.post(SITE_BASE_PATH+"MachineInfo/machineChinPath", {planCount:treeStringFinall},function(result){//这是我后台的地址,主要用于获取参数
                //alert(result[0].);
                if(result){
                for(var i=0;i<result.length;i++){
              var getchinObject = new Object();
              getchinObject.parentpath=result[i].parentpath;//这里进行了数据的封装
              getchinObject.id=i;
              getchinObject.text=result[i].path;
              if(1 == result[i].state){
              getchinObject.state = "closed";
              }else{
              getchinObject.state = "open";
              }
              treeChinArray.push(getchinObject);
              }
                // alert(node.target);
                $("#tree").tree('append',{//这里是展示子节点的方法!
                parent:node.target,
                data:treeChinArray
                }); 
                }
                 },"JSON");
               },
        onSelect: function (item) { 
                       //alert(item.parentpath+"/"+item.text);
                       $("#localFile").val(item.parentpath+"/"+item.text);//这个是被选中的方法
                } 
}); 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值