Showing
1 changed file
with
21 additions
and
5 deletions
1 | /** | 1 | /** |
2 | * Created by frw on 2016/6/17. | 2 | * Created by frw on 2016/6/17. |
3 | */ | 3 | */ |
4 | + | ||
5 | +var selectedNodeId = null; | ||
6 | + | ||
4 | var treeData = []; | 7 | var treeData = []; |
5 | var nodeId2id = function (nodeid) { | 8 | var nodeId2id = function (nodeid) { |
6 | if (nodeid == "#") { | 9 | if (nodeid == "#") { |
@@ -141,9 +144,23 @@ $("#btn4type").click(function () { | @@ -141,9 +144,23 @@ $("#btn4type").click(function () { | ||
141 | /** | 144 | /** |
142 | * 根据选中的节点获取信息 | 145 | * 根据选中的节点获取信息 |
143 | */ | 146 | */ |
144 | -function searchType(ip){ | 147 | +function searchType(ip, children, nodeId){ |
148 | + | ||
149 | + //非叶子节点不处理 | ||
150 | + if(children.length != 0) { | ||
151 | + return; | ||
152 | + } | ||
153 | + | ||
154 | + //将原来选中的节点的背景颜色去掉 | ||
155 | + if(selectedNodeId != null) { | ||
156 | + document.getElementById(selectedNodeId).style.backgroundColor="transparent"; | ||
157 | + } | ||
158 | + | ||
159 | + //给选中的节点添加背景颜色 | ||
160 | + document.getElementById(nodeId).style.backgroundColor="#CCCCCC"; | ||
161 | + selectedNodeId = nodeId; | ||
162 | + | ||
145 | $("#detailTable").hide(); | 163 | $("#detailTable").hide(); |
146 | -// $("#rootTable").table("load",{}); | ||
147 | $("#rootTable").table({ | 164 | $("#rootTable").table({ |
148 | url: contextPath + "/zkTree/getRoot?ip="+ip, | 165 | url: contextPath + "/zkTree/getRoot?ip="+ip, |
149 | striped: true, | 166 | striped: true, |
@@ -185,7 +202,6 @@ function searchType(ip){ | @@ -185,7 +202,6 @@ function searchType(ip){ | ||
185 | } | 202 | } |
186 | }], | 203 | }], |
187 | }); | 204 | }); |
188 | - | ||
189 | } | 205 | } |
190 | 206 | ||
191 | 207 | ||
@@ -280,7 +296,7 @@ var refreshTypeTree = function () { | @@ -280,7 +296,7 @@ var refreshTypeTree = function () { | ||
280 | 296 | ||
281 | 297 | ||
282 | $('#jstree').jstree({ | 298 | $('#jstree').jstree({ |
283 | - "plugins": ["themes", "checkbox", "contextmenu", "ui", "types", "crrm", "core", "status"], | 299 | + "plugins": ["themes", "contextmenu", "ui", "types", "crrm", "core", "status"], |
284 | 'core': { | 300 | 'core': { |
285 | "themes": { | 301 | "themes": { |
286 | name: 'proton', | 302 | name: 'proton', |
@@ -294,6 +310,6 @@ $('#jstree').jstree({ | @@ -294,6 +310,6 @@ $('#jstree').jstree({ | ||
294 | function (e, data) { | 310 | function (e, data) { |
295 | console.log(data); | 311 | console.log(data); |
296 | console.log("Checked: " + data.node.text); | 312 | console.log("Checked: " + data.node.text); |
297 | - searchType(data.node.text); | 313 | + searchType(data.node.text, data.node.children, data.node.a_attr.id); |
298 | }); | 314 | }); |
299 | refreshTypeTree(); | 315 | refreshTypeTree(); |
-
Please register or login to post a comment