Home  >  Article  >  Web Front-end  >  Several methods for automatically folding and expanding JS operating tree nodes_javascript skills

Several methods for automatically folding and expanding JS operating tree nodes_javascript skills

WBOY
WBOYOriginal
2016-05-16 16:49:551907browse

1. Method 1

Copy code The code is as follows:

var tree = L5.getCmp(' edocOutfileRelationTree');
//Add selection tree, nodes will automatically collapse
tree.on("click", function(node,e){
node.getUI().toggleCheck(true);
});
tree.root.expand();

2. Method 2
Copy code The code is as follows:

var tree = L5.getCmp('orgstrutree');
//Add a selection tree and the nodes will automatically collapse
tree.on("click" , function(node,e){
if(node.expanded==false){
node.expand();
}else{
node.collapse();
}
});

Used in conjunction with:
Copy code The code is as follows:

var tree = L5.getCmp('orgstrutree');
//Add selection tree, nodes will automatically collapse
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();
}
}
});
} >
Statement:
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