zTree实现单击展开树

需要更改的部分如下:

var setting = {
view: {
dblClickExpand: false//屏蔽掉双击事件
},
data: {
simpleData: {
enable: true
}
},
callback: {
onClick: onClick
}
};


var zNodes =[
{ id:1, pId:0, name:"根 Root", open:true},
{ id:11, pId:1, name:"父节点 1-1", open:true},
{ id:111, pId:11, name:"叶子节点 1-1-1"},
{ id:112, pId:11, name:"叶子节点 1-1-2"},
{ id:113, pId:11, name:"叶子节点 1-1-3"},
{ id:114, pId:11, name:"叶子节点 1-1-4"},
{ id:12, pId:1, name:"父节点 1-2", open:true},
{ id:121, pId:12, name:"叶子节点 1-2-1"},
{ id:122, pId:12, name:"叶子节点 1-2-2"},
{ id:123, pId:12, name:"叶子节点 1-2-3"},
{ id:124, pId:12, name:"叶子节点 1-2-4"},
{ id:13, pId:1, name:"父节点 1-3", open:true},
{ id:131, pId:13, name:"叶子节点 1-3-1"},
{ id:132, pId:13, name:"叶子节点 1-3-2"},
{ id:133, pId:13, name:"叶子节点 1-3-3"},
{ id:134, pId:13, name:"叶子节点 1-3-4"}
];


function onClick(e,treeId, treeNode) {
var zTree = $.fn.zTree.getZTreeObj("treeDemo");
zTree.expandNode(treeNode);
}


$(document).ready(function(){
$.fn.zTree.init($("#treeDemo"), setting, zNodes);
});

 


阅读更多
换一批

没有更多推荐了,返回首页