EXT4 동적 트리
7301 단어 ext4
프런트엔드 js 코드:
//
function createXxTrees(){
var xxMenuArr = [{
text: "XXX ",
expanded: false,
iconCls:"leftMenuIcon",
icon:"images/node/utcs/folder.jpg",
children: [{
text: " ",
iconCls:"leftMenuIcon",
icon:"images/node/utcs/bianji.png",
leaf: true
},{
text: " ",
iconCls:"leftMenuIcon",
icon:"images/node/utcs/bianji.png",
leaf: true
},{
text: " ",
iconCls:"leftMenuIcon",
icon:"images/node/utcs/bianji.png",
leaf: true
}
]
}
];
//
Ext.Ajax.request({
url : 'XxTreeAction.action',
//params : {},
success : function(response,returnValue)
{
var info = Ext.JSON.decode(response.responseText);
var nodes = info.nodes;
if(info.success){
var nodeRoot = {
text:" ",
expanded: true,
iconCls:"leftMenuIcon",
icon:"images/node/utcs/folder.jpg",
children: nodes
}
xxMenuArr.push(nodeRoot);
}
},
failure : function(response)
{
},
async: false
});
xxTreeStore = Ext.create('Ext.data.TreeStore', {
root: {
expanded: true,
children: xxMenuArr
}
});
//
if (Ext.getCmp(' xxTreePanel ') == null ) {
Ext.create('Ext.tree.Panel', {
id: 'xxTreePanel',
width: leftMenuWidth,
height: leftMenuHeight,
store: xxTreeStore ,
rootVisible: false,
renderTo: "xxDivId",//HTML DIV Id
listeners: {
itemclick: function(view, record, element, index){
}
}
});
}
}
백그라운드 XxTreeAction 실행 방법 코드:
public String execute() throws Exception
{
List<TreeNode> serverTreeList = new ArrayList<TreeNode>();//
List<TreeNode> childrenTreeList = new ArrayList<TreeNode>();
try {
List<KkServerInfo> serverInfoList = serverService.findAll();
//
for(int i=0;i<serverInfoList.size();i++){
KkServerInfo serverInfo = serverInfoList.get(i);
long serverId = serverInfo.getId();
//
TreeNode serverTreeNode = new TreeNode();
serverTreeNode.setText(serverInfo.getKkServerName());
serverTreeNode.setId("s#"+serverInfo.getId());
serverTreeNode.setCls("");
serverTreeNode.setIconCls("leftMenuIcon");
serverTreeNode.setIcon("images/node/utcs/server.jpg");
serverTreeNode.setExpanded(true);
//
List<TreeNode> areaTreaNodeList = new ArrayList<TreeNode>();
List<KkDomain> areaInfoList = areaService.selectKkAreaListByServerId(serverId);
//
for(int j=0;j<areaInfoList.size();j++){
KkDomain areaInfo = areaInfoList.get(j);
long areaId = areaInfo.getId();
//
TreeNode areaTreeNode = new TreeNode();
areaTreeNode.setText(areaInfo.getName());
areaTreeNode.setId("a#"+areaInfo.getId());
areaTreeNode.setCls("");
areaTreeNode.setIconCls("leftMenuIcon");
areaTreeNode.setIcon("images/node/utcs/yu.jpg");
areaTreeNode.setExpanded(false);
//
List<TreeNode> nodeTreeNodeList = new ArrayList<TreeNode>();
List<KkInfo> nodeInfoList = nodeService.selectKkInfoListByAreaId(areaId);
//
for(int m=0;m<nodeInfoList.size();m++){
KkInfo nodeInfo = nodeInfoList.get(m);
//
TreeNode nodeTreeNode = new TreeNode();
nodeTreeNode.setText(nodeInfo.getAddress());
nodeTreeNode.setId("n#"+nodeInfo.getId());
nodeTreeNode.setCls("");
nodeTreeNode.setLeaf(true);
nodeTreeNode.setIconCls("leftMenuIcon");
nodeTreeNode.setIcon("images/node/kkcs/kkcs.png");
nodeTreeNode.setChildren(childrenTreeList);
nodeTreeNodeList.add(nodeTreeNode);
}//end
areaTreeNode.setChildren(nodeTreeNodeList);
areaTreaNodeList.add(areaTreeNode);//
}//end
serverTreeNode.setChildren(areaTreaNodeList);
serverTreeList.add(serverTreeNode);
}//end
success = true;
} catch (Exception e) {
e.printStackTrace();
success = false;
}
this.nodes = serverTreeList;
return SUCCESS;
}
NodeTree.java 클래스: (TreeStore에서 트리 노드의 속성이 봉인됨)
import java.util.List;
/**
*
* @author
*
*/
public class TreeNode {
private String text;
private String id;
private String cls;
private boolean expanded;
private String iconCls;
private String icon;
private String href;
private boolean leaf;
private List<TreeNode> children;
public String getIcon() {
return icon;
}
public void setIcon(String icon) {
this.icon = icon;
}
public String getHref() {
return href;
}
public String getIconCls() {
return iconCls;
}
public void setIconCls(String iconCls) {
this.iconCls = iconCls;
}
public void setHref(String href) {
this.href = href;
}
public boolean isLeaf() {
return leaf;
}
public void setLeaf(boolean leaf) {
this.leaf = leaf;
}
public List<TreeNode> getChildren() {
return children;
}
public void setChildren(List<TreeNode> children) {
this.children = children;
}
public boolean isExpanded() {
return expanded;
}
public void setExpanded(boolean expanded) {
this.expanded = expanded;
}
public String getText() {
return text;
}
public void setText(String text) {
this.text = text;
}
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getCls() {
return cls;
}
public void setCls(String cls) {
this.cls = cls;
}
}
이 내용에 흥미가 있습니까?
현재 기사가 여러분의 문제를 해결하지 못하는 경우 AI 엔진은 머신러닝 분석(스마트 모델이 방금 만들어져 부정확한 경우가 있을 수 있음)을 통해 가장 유사한 기사를 추천합니다:
Ext4 treePanel checkBox 선택 예텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
CC BY-SA 2.5, CC BY-SA 3.0 및 CC BY-SA 4.0에 따라 라이센스가 부여됩니다.