Home > Web Front-end > JS Tutorial > body text

Js操作树节点自动折叠展开的几种方法_javascript技巧

WBOY
Release: 2016-05-16 16:49:55
Original
1871 people have browsed it

1、方法一

复制代码 代码如下:

var tree = L5.getCmp('edocOutfileRelationTree');
//增加选择树,节点自动折叠
tree.on("click", function(node,e){
node.getUI().toggleCheck(true);
});
tree.root.expand();

2、方法二
复制代码 代码如下:

var tree = L5.getCmp('orgstrutree');
//增加选择树,节点自动折叠
tree.on("click", function(node,e){
if(node.expanded==false){
node.expand();
}else{
node.collapse();
}
});

结合使用:
复制代码 代码如下:

var tree = L5.getCmp('orgstrutree');
//增加选择树,节点自动折叠
tree.on("click", function(node,e){
var organType = node.record.get("organType");
if(organType == "8"){
node.getUI().toggleCheck(true);
}else{
if(node.expanded==false){
node.expand();
}else{
node.collapse();
}
}
});
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!