这里说名的是js中生成json arry是js中定义的json 树插件是jquery.ztree

 

var param = {

};
$.post("manager_treeList", param, function(data) {
//循环列表
var setting = {
view: {
dblClickExpand: false,
showLine: true,
selectedMulti: false
},
data: {
simpleData: {
enable:true,
idKey: "id",
pIdKey: "pId",
rootPId: ""
}
},
callback: {
onClick: zTreeOnClick
}
};

var arry = [];
//biaoqian类
var BiaoQianBean = {
id:"",
box_num:"",
thumb_url:"",
type:"sys",
addtime:""
};

$.each(data.managerTree,function(i, tmp) {
if(tmp.pid=="0")
{
var BiaoQianBean = {
id:tmp.id,
pId:tmp.pid,
name:tmp.pointName,
open:true
};
}
else
{
var BiaoQianBean = {
id:tmp.id,
pId:tmp.pid,
name:tmp.pointName
};
}
arry.push(BiaoQianBean);

});

var zTreeDemo = $.fn.zTree.init($("#user_tree"),setting, arry);
});