ztree的异步加载

js中代码为:

//参数设置:

var setting = {

 async: {    

      enable: true,

        url:"<%=path%>/role/getTreeData",

       autoParam:["id"]

      },

  callback: {

       onAsyncSuccess: zTreeOnAsyncSuccess,  

      }

};

//显示一级节点

function zTreeOnAsyncSuccess(event, treeId, treeNode, msg) {
     var zTree = $.fn.zTree.getZTreeObj("mytree");     
     var nodes = zTree.getNodes(); 
     zTree.expandNode(nodes[0], true); 
};

//树的加载

$(function() { 
 $.fn.zTree.init($("#mytree"), setting);
});

java端的测试数据:
[{ id:'01', name:'n1', isParent:true},{ id:'02', name:'n2', isParent:false},{ id:'03', name:'n3', isParent:true},{ id:'04', name:'n4', isParent:false}]

 

 

 

posted @ 2013-07-18 15:48  姜莹莹  阅读(798)  评论(0编辑  收藏  举报