7e775553e1e1a50c8e10d719cefb4792795038f1.svn-base 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460
  1. <%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
  2. <%
  3. String path = request.getContextPath();
  4. %>
  5. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  6. <html xmlns="http://www.w3.org/1999/xhtml">
  7. <head>
  8. <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
  9. <title>树下拉框</title>
  10. <!--框架必需start-->
  11. <script type="text/javascript" src="<%=path%>/libs/js/jquery.js"></script>
  12. <script type="text/javascript" src="<%=path%>/libs/js/language/cn.js"></script>
  13. <script type="text/javascript" src="<%=path%>/libs/js/framework.js"></script>
  14. <link href="<%=path%>/libs/css/import_basic.css" rel="stylesheet" type="text/css"/>
  15. <link rel="stylesheet" type="text/css" id="skin" prePath="<%=path%>/"/>
  16. <link rel="stylesheet" type="text/css" id="customSkin"/>
  17. <!--框架必需end-->
  18. <!-- 树组件start -->
  19. <script type="text/javascript" src="<%=path%>/libs/js/tree/ztree/ztree.js"></script>
  20. <link type="text/css" rel="stylesheet" href="<%=path%>/libs/js/tree/ztree/ztree.css"></link>
  21. <!-- 树组件end -->
  22. <!-- 树形下拉框start -->
  23. <script type="text/javascript" src="<%=path%>/libs/js/form/selectTree.js"></script>
  24. <!-- 树形下拉框end -->
  25. </head>
  26. <body>
  27. <div class="box1" panelWidth="800">
  28. <fieldset>
  29. <legend>1、使用url赋值</legend>
  30. <div class="red">此示例由后台支持</div>
  31. <div class="selectTree" url="<%=path%>/getDepartmentsTree.action" id="selectTree1"></div>
  32. <br/><input type="button" value="获取值" onclick="getValue()"/>
  33. </fieldset>
  34. <div class="height_15"></div>
  35. <fieldset>
  36. <legend>2、使用url+参数赋值</legend>
  37. <div class="red">此示例由后台支持</div>
  38. <div class="selectTree" url="<%=path%>/getDepartmentsTree.action" params='{"organization.orgId":"1"}'></div>
  39. </fieldset>
  40. <div class="height_15"></div>
  41. <fieldset>
  42. <legend>3、赋值给标签的data属性</legend>
  43. <p>注意:使用json格式的字符串时所有节点的属性名与值都必须使用双引号</p>
  44. <div class="selectTree" data='{"treeNodes":[{ "id":"1", "parentId":"0", "name":"部门1", "open": "true"},{ "id":"11", "parentId":"1", "name":"员工1"},{ "id":"12", "parentId":"1", "name":"员工2"},{ "id":"13", "parentId":"1", "name":"员工3"},{ "id":"2", "parentId":"0", "name":"部门2", "open": "true"},{ "id":"21", "parentId":"2", "name":"员工4"}]}'></div>
  45. </fieldset>
  46. <div class="height_15"></div>
  47. <fieldset>
  48. <legend>4、动态设置data</legend>
  49. 使用本地数据:<br/>
  50. <div class="selectTree" id="selectTree4-1" keepDefaultStyle="true"></div>
  51. <br/>
  52. <br/>
  53. 使用远程数据:
  54. <div class="red">此示例由后台支持</div>
  55. <div class="selectTree" id="selectTree4-2" keepDefaultStyle="true"></div>
  56. </fieldset>
  57. <div class="height_15"></div>
  58. <fieldset>
  59. <legend>5、使用隐藏域</legend>
  60. <p>如果为组件添加name属性,那么会自动生成一个隐藏域input,用来存储组件当前的value,该input的name与组件name一致。<br/>在提交表单时会用到。</p>
  61. <div class="selectTree" name="selectTree5" data='{"treeNodes":[{ "id":"1", "parentId":"0", "name":"部门1", "open": "true"},{ "id":"11", "parentId":"1", "name":"员工1"},{ "id":"12", "parentId":"1", "name":"员工2"},{ "id":"13", "parentId":"1", "name":"员工3"},{ "id":"2", "parentId":"0", "name":"部门2", "open": "true"},{ "id":"21", "parentId":"2", "name":"员工4"}]}'></div>
  62. <br/><input type="button" value="获取隐藏域选中值" onclick="getHiddenValue()"/>
  63. </fieldset>
  64. <div class="height_15"></div>
  65. <fieldset>
  66. <legend>6、change事件</legend>
  67. 使用bind方法绑定change事件<br/>
  68. <div class="selectTree" id="selectTree6" data='{"treeNodes":[{ "id":"1", "parentId":"0", "name":"部门1", "open": "true"},{ "id":"11", "parentId":"1", "name":"员工1"},{ "id":"12", "parentId":"1", "name":"员工2"},{ "id":"13", "parentId":"1", "name":"员工3"},{ "id":"2", "parentId":"0", "name":"部门2", "open": "true"},{ "id":"21", "parentId":"2", "name":"员工4"}]}'></div>
  69. </fieldset>
  70. <div class="height_15"></div>
  71. <fieldset>
  72. <legend>7、设置某些节点不可选择</legend>
  73. <p>设置父节点不可选时,点击父节点会自动展开子节点。<br/>
  74. 除父节点外,子节点也可设置不可选。</p>
  75. <div class="selectTree" data='{"treeNodes":[{ "id":"1", "parentId":"0", "name":"部门1","clickExpand":"true"},{ "id":"11", "parentId":"1", "name":"员工1"},{ "id":"12", "parentId":"1", "name":"员工2"},{ "id":"13", "parentId":"1", "name":"员工3"},{ "id":"2", "parentId":"0", "name":"部门2","clickExpand":"true"},{ "id":"21", "parentId":"2", "name":"员工4(不可选)","clickExpand":"true"}]}'></div>
  76. </fieldset>
  77. <div class="height_15"></div>
  78. <fieldset>
  79. <legend>8、禁用/启用</legend>
  80. <div class="selectTree" id="selectTree8" disabled="true" data='{"treeNodes":[{ "id":"1", "parentId":"0", "name":"部门1", "open": "true"},{ "id":"11", "parentId":"1", "name":"员工1"},{ "id":"12", "parentId":"1", "name":"员工2"},{ "id":"13", "parentId":"1", "name":"员工3"},{ "id":"2", "parentId":"0", "name":"部门2", "open": "true"},{ "id":"21", "parentId":"2", "name":"员工4"}]}'></div>
  81. <br/>
  82. <input type="button" value="启用" onclick="enableSelectTree()"/>
  83. <input type="button" value="禁用" onclick="disableSelectTree()"/>
  84. </fieldset>
  85. <div class="height_15"></div>
  86. <fieldset>
  87. <legend>9、自定义图标</legend>
  88. <div class="selectTree" id="selectTree9" keepDefaultStyle="true"></div>
  89. </fieldset>
  90. <div class="height_15"></div>
  91. <fieldset>
  92. <legend>10、宽度、高度与方向</legend>
  93. 下拉框默认为120px宽度,当有较长的选项时,下拉框宽度默认不变,而选项容器宽度自适应<br/>
  94. <div class="selectTree" data='{"treeNodes":[{ "id":"1", "parentId":"0", "name":"部门1", "open": "false"},{ "id":"11", "parentId":"1", "name":"很长的选项很长的选项"},{ "id":"12", "parentId":"1", "name":"员工2"},{ "id":"13", "parentId":"1", "name":"员工3"},{ "id":"2", "parentId":"0", "name":"部门2", "open": "true"},{ "id":"21", "parentId":"2", "name":"员工4"}]}'></div>
  95. <br/><br/>
  96. 单独设置下拉框宽度,选项容器宽度默认不会小于下拉框宽度<br/>
  97. <div class="selectTree" selWidth="250" data='{"treeNodes":[{ "id":"1", "parentId":"0", "name":"部门1", "open": "true"},{ "id":"11", "parentId":"1", "name":"很长的选项很长的选项"},{ "id":"12", "parentId":"1", "name":"员工2"},{ "id":"13", "parentId":"1", "name":"员工3"},{ "id":"2", "parentId":"0", "name":"部门2", "open": "true"},{ "id":"21", "parentId":"2", "name":"员工4"}]}'></div>
  98. <br/><br/>
  99. 自定义容器高度<br/>
  100. <div class="selectTree" boxHeight="100" data='{"treeNodes":[{ "id":"1", "parentId":"0", "name":"部门1", "open": "true"},{ "id":"11", "parentId":"1", "name":"很长的选项很长的选项"},{ "id":"12", "parentId":"1", "name":"员工2"},{ "id":"13", "parentId":"1", "name":"员工3"},{ "id":"2", "parentId":"0", "name":"部门2", "open": "true"},{ "id":"21", "parentId":"2", "name":"员工4"}]}'></div>
  101. <br/><br/>
  102. 强制向上展开<br/>
  103. <div class="selectTree" openDirection="top" data='{"treeNodes":[{ "id":"1", "parentId":"0", "name":"部门1", "open": "true"},{ "id":"11", "parentId":"1", "name":"很长的选项很长的选项"},{ "id":"12", "parentId":"1", "name":"员工2"},{ "id":"13", "parentId":"1", "name":"员工3"},{ "id":"2", "parentId":"0", "name":"部门2", "open": "true"},{ "id":"21", "parentId":"2", "name":"员工4"}]}'></div>
  104. </fieldset>
  105. <div class="height_15"></div>
  106. <fieldset>
  107. <legend>11、可编辑树形下拉框</legend>
  108. <div class="selectTree" id="selectTree11" editable="true" data='{"treeNodes":[{ "id":"1", "parentId":"0", "name":"部门1", "open": "true"},{ "id":"11", "parentId":"1", "name":"员工1"},{ "id":"12", "parentId":"1", "name":"员工2"},{ "id":"13", "parentId":"1", "name":"员工3"},{ "id":"2", "parentId":"0", "name":"部门2", "open": "true"},{ "id":"21", "parentId":"2", "name":"员工4"}]}'></div>
  109. <br/><input type="button" value="获取值" onclick="getEditSelectValue()"/>
  110. </fieldset>
  111. <div class="height_15"></div>
  112. <fieldset>
  113. <legend>12、设置初始值</legend>
  114. <div class="selectTree" id="selectTree12" selectedValue="13" data='{"treeNodes":[{ "id":"1", "parentId":"0", "name":"部门1", "open": "true"},{ "id":"11", "parentId":"1", "name":"员工1"},{ "id":"12", "parentId":"1", "name":"员工2"},{ "id":"13", "parentId":"1", "name":"员工3"},{ "id":"2", "parentId":"0", "name":"部门2", "open": "true"},{ "id":"21", "parentId":"2", "name":"员工4"}]}'></div>
  115. <br/><input type="button" value="获取值" onclick="getSelectValue()"/>
  116. </fieldset>
  117. <div class="height_15"></div>
  118. <fieldset>
  119. <legend>13、多选下拉框与多选树形下拉框</legend>
  120. <p>在此框架中,多选下拉框是树形下拉框的一种使用模式,详情见“多选下拉框”。</p>
  121. </fieldset>
  122. <div class="height_15"></div>
  123. <fieldset>
  124. <legend>14、动态生成树形下拉框</legend>
  125. <div class="red">此示例由后台支持</div>
  126. <input type="button" value="点击生成(使用url)" style="width:120px;" id="testBtn" onclick="dynamicSelTreebox1()"/><br/><br/>
  127. <input type="button" value="点击生成(使用data)" style="width:120px;" id="testBtn2" onclick="dynamicSelTreebox2()"/>
  128. </fieldset>
  129. <div class="height_15"></div>
  130. <fieldset>
  131. <legend>15、动态修改树形下拉框</legend>
  132. <div class="selectTree" id="selectTree15" data='{"treeNodes":[{ "id":"1", "parentId":"0", "name":"部门1", "open": "true"},{ "id":"11", "parentId":"1", "name":"员工1"},{ "id":"12", "parentId":"1", "name":"员工2"},{ "id":"13", "parentId":"1", "name":"员工3"},{ "id":"2", "parentId":"0", "name":"部门2", "open": "true"},{ "id":"21", "parentId":"2", "name":"员工4"}]}'></div>
  133. <br/><br/><input type="button" value="选中“员工1”" onclick="selectSecondItem()" style="width:105px;"/>
  134. <input type="button" value="追加一项" onclick="appendItem()" style="width:105px;"/>
  135. <input type="button" value="移除“员工2”" onclick="removeItem()" style="width:105px;"/>
  136. </fieldset>
  137. <div class="height_15"></div>
  138. <fieldset>
  139. <legend>16、节点集成动态操作(自定义的树形下拉框)</legend>
  140. <div id="customSelectTree" keepDefaultStyle="true" selWidth="200" data='{"treeNodes":[{ "id":"1", "parentId":"0", "name":"部门1", "open": "true"},{ "id":"11", "parentId":"1", "name":"员工1"},{ "id":"12", "parentId":"1", "name":"员工2"},{ "id":"13", "parentId":"1", "name":"员工3"},{ "id":"2", "parentId":"0", "name":"部门2", "open": "true"},{ "id":"21", "parentId":"2", "name":"员工4"}]}'></div>
  141. </fieldset>
  142. <div class="height_15"></div>
  143. <fieldset>
  144. <legend>17、重置树形下拉框</legend>
  145. <form id="form-17">
  146. <table class="tableStyle" formMode="transparent" style="width:400px;">
  147. <tr>
  148. <td>传统表单元素:</td>
  149. <td><input type="text"/></td>
  150. </tr>
  151. <tr>
  152. <td>树形下拉框1:</td>
  153. <td><div class="selectTree" data='{"treeNodes":[{ "id":"1", "parentId":"0", "name":"部门1", "open": "true"},{ "id":"11", "parentId":"1", "name":"员工1"},{ "id":"12", "parentId":"1", "name":"员工2"},{ "id":"13", "parentId":"1", "name":"员工3"},{ "id":"2", "parentId":"0", "name":"部门2", "open": "true"},{ "id":"21", "parentId":"2", "name":"员工4"}]}'></div></td>
  154. </tr>
  155. <tr>
  156. <td>树形下拉框2:</td>
  157. <td><div class="selectTree" selectedValue="21" data='{"treeNodes":[{ "id":"1", "parentId":"0", "name":"部门1", "open": "true"},{ "id":"11", "parentId":"1", "name":"员工1"},{ "id":"12", "parentId":"1", "name":"员工2"},{ "id":"13", "parentId":"1", "name":"员工3"},{ "id":"2", "parentId":"0", "name":"部门2", "open": "true"},{ "id":"21", "parentId":"2", "name":"员工4"}]}'></div></td>
  158. </tr>
  159. <tr>
  160. <td colspan="2">
  161. <input type="button" value="提交"/>
  162. <input type="button" value="重置" onclick="resetForm()"/>
  163. </td>
  164. </tr>
  165. </table>
  166. </form>
  167. </fieldset>
  168. <div class="height_15"></div>
  169. <fieldset>
  170. <legend>18、获得选中节点自定义属性</legend>
  171. <div class="selectTree" id="selectTree18" data='{"treeNodes":[{ "id":"1", "parentId":"0", "name":"部门1", "open": "true","myFlag":"部门1-自定义属性"},{ "id":"11", "parentId":"1", "name":"员工1","myFlag":"员工1-自定义属性"},{ "id":"12", "parentId":"1", "name":"员工2","myFlag":"员工2-自定义属性"},{ "id":"13", "parentId":"1", "name":"员工3","myFlag":"员工3-自定义属性"},{ "id":"2", "parentId":"0", "name":"部门2", "open": "true","myFlag":"部门2-自定义属性"},{ "id":"21", "parentId":"2", "name":"员工4","myFlag":"员工4-自定义属性"}]}'></div>
  172. </fieldset>
  173. <div class="height_15"></div>
  174. <fieldset>
  175. <legend>19、节点异步加载</legend>
  176. <div class="red">此示例由后台支持</div>
  177. <div class="selectTree" asyncMode="true" url="<%=path%>/getAsyncTree.action"></div>
  178. </fieldset>
  179. <div class="height_15"></div>
  180. <fieldset>
  181. <legend>20、数据无前缀</legend>
  182. <div class="selectTree" data='[{ "id":"1", "parentId":"0", "name":"部门1", "open": "true"},{ "id":"11", "parentId":"1", "name":"员工1"},{ "id":"12", "parentId":"1", "name":"员工2"},{ "id":"13", "parentId":"1", "name":"员工3"},{ "id":"2", "parentId":"0", "name":"部门2", "open": "true"},{ "id":"21", "parentId":"2", "name":"员工4"}]'></div>
  183. </fieldset>
  184. <div class="height_15"></div>
  185. </div>
  186. <script type="text/javascript">
  187. /*构建树节点数据*/
  188. var defaultNodes = {"treeNodes":[
  189. { id:1, parentId:0, name:"部门1", open: true},
  190. { id:11, parentId:1, name:"员工1"},
  191. { id:12, parentId:1, name:"员工2"},
  192. { id:13, parentId:1, name:"员工3"},
  193. { id:2, parentId:0, name:"部门2", open: true},
  194. { id:21, parentId:2, name:"员工4"}
  195. ]};
  196. var iconNodes = {"treeNodes":[
  197. { id:1, parentId:0, name:"部门1",clickExpand:true,icon:"<%=path%>/libs/icons/user_group.gif"},
  198. { id:11, parentId:1, name:"员工1",icon:"<%=path%>/libs/icons/user.gif"},
  199. { id:12, parentId:1, name:"员工2",icon:"<%=path%>/libs/icons/user_female.gif"},
  200. { id:13, parentId:1, name:"员工3",icon:"<%=path%>/libs/icons/user_worker.gif"},
  201. { id:2, parentId:0, name:"部门2",clickExpand:true,icon:"<%=path%>/libs/icons/user_group.gif"},
  202. { id:21, parentId:2, name:"员工4",icon:"<%=path%>/libs/icons/user.gif"}
  203. ]};
  204. function initComplete(){
  205. //赋给data属性
  206. $("#selectTree4-1").data("data",defaultNodes);
  207. $("#selectTree4-1").render();
  208. //获取远程数据
  209. $.post("<%=path%>/getDepartmentsTree.action",{},function(result){
  210. //赋给data属性
  211. $("#selectTree4-2").data("data",result);
  212. //刷新树形下拉框
  213. $("#selectTree4-2").render();
  214. },"json");
  215. //绑定change事件
  216. $("#selectTree6").bind("change",function(){
  217. if(!$(this).attr("relValue")){
  218. top.Dialog.alert("没有选择节点");
  219. }else{
  220. top.Dialog.alert("选中节点文本:"+$(this).attr("relText")+"<br/>选中节点值:"+$(this).attr("relValue"));
  221. }
  222. })
  223. //赋给data属性
  224. $("#selectTree9").data("data",iconNodes);
  225. $("#selectTree9").render();
  226. //渲染自定义下拉框
  227. $("#customSelectTree").selectTreeRender(setting17);
  228. //数据自定义属性
  229. $("#selectTree18").bind("change",function(){
  230. if(!$(this).attr("relValue")){
  231. top.Dialog.alert("没有选择节点");
  232. }else{
  233. var node=$(this).data("selectedNode");
  234. top.Dialog.alert(node.myFlag);
  235. }
  236. })
  237. }
  238. //获取值
  239. function getValue(){
  240. top.Dialog.alert("选中节点文本:"+$("#selectTree1").attr("relText")+"<br/>选中节点id:"+$("#selectTree1").attr("relValue"));
  241. }
  242. //获取隐藏域值
  243. function getHiddenValue(){
  244. top.Dialog.alert($("input:hidden[name='selectTree5']").val());
  245. }
  246. //禁用
  247. function disableSelectTree(){
  248. $("#selectTree8").attr("disabled",true);
  249. $("#selectTree8").render();
  250. }
  251. //启用
  252. function enableSelectTree(){
  253. $("#selectTree8").attr("disabled",false);
  254. $("#selectTree8").render();
  255. }
  256. //通过editValue属性获取下拉树的文本值,包括编辑的文本 及 选中的文本
  257. function getEditSelectValue(){
  258. top.Dialog.alert($("#selectTree11").attr("editValue"));
  259. }
  260. //获取选择值
  261. function getSelectValue(){
  262. top.Dialog.alert("选中节点文本:"+$("#selectTree12").attr("relText")+"<br/>选中节点id:"+$("#selectTree12").attr("relValue"));
  263. }
  264. //动态生成树形下拉框(使用url)
  265. function dynamicSelTreebox1(){
  266. //获取远程数据
  267. var $selTree = $('<div class="selectTree"></div>');
  268. //设置url属性
  269. $selTree.attr("url","<%=path%>/getDepartmentsTree.action");
  270. //将下拉框加到按钮的后面
  271. $("#testBtn").after($selTree);
  272. $("#testBtn").after("<br/>");
  273. //渲染树形下拉框
  274. $selTree.render();
  275. }
  276. //动态生成树形下拉框(使用data)
  277. function dynamicSelTreebox2(){
  278. //获取远程数据
  279. $.post("<%=path%>/getDepartmentsTree.action",{},function(result){
  280. var $selTree = $('<div class="selectTree"></div>');
  281. //赋给data属性
  282. $selTree.data("data",result);
  283. //将下拉框加到按钮的后面
  284. $("#testBtn2").after($selTree);
  285. $("#testBtn2").after("<br/>");
  286. //渲染树形下拉框
  287. $selTree.render();
  288. },"json");
  289. }
  290. //动态选中项
  291. function selectSecondItem(){
  292. $("#selectTree15").setValue("11");
  293. }
  294. //追加一项
  295. function appendItem(){
  296. $("#selectTree15").addItem({id:100, parentId:2, name:"员工5"});
  297. $("#selectTree15").setValue("100");
  298. }
  299. //移除项
  300. function removeItem(){
  301. $("#selectTree15").removeItem("12");
  302. }
  303. //表单重置
  304. function resetForm(){
  305. $("#form-17")[0].reset();
  306. $("#form-17 .selectTree").resetValue();
  307. }
  308. /*以下为示例16所用到*/
  309. //自定义树形下拉框的设置
  310. var setting17 = {
  311. view: {
  312. addHoverDom: addHoverDom,
  313. removeHoverDom: removeHoverDom,
  314. selectedMulti: false
  315. },
  316. edit: {
  317. enable: true,
  318. renameTitle:"修改",
  319. removeTitle:"删除"
  320. },
  321. data: {
  322. simpleData: {
  323. enable: true
  324. }
  325. },
  326. callback: {
  327. onClick: zTreeSelectItemClick,
  328. //不允许拖拽
  329. beforeDrag: beforeDrag,
  330. //修改完时的处理
  331. beforeRename: beforeRename,
  332. //修改成功后处理
  333. onRename: onRename,
  334. onRemove:onRemove
  335. }
  336. };
  337. //不允许拖拽
  338. function beforeDrag(treeId, treeNodes) {
  339. return false;
  340. }
  341. //修改完时的处理
  342. function beforeRename(treeId, treeNode, newName) {
  343. if (newName.length == 0) {
  344. alert("节点名称不能为空.");
  345. var treeContainer=$("#customSelectTree ul[class=ztree]");
  346. var zTree = $.fn.zTree.getZTreeObj(treeContainer.attr("id"));
  347. setTimeout(function(){
  348. zTree.editName(treeNode)
  349. }, 10);
  350. return false;
  351. }
  352. return true;
  353. }
  354. //修改成功后处理
  355. function onRename(e, treeId, treeNode) {
  356. //此处进行ajax后台数据处理
  357. }
  358. //删除处理
  359. function onRemove(treeId, treeNode) {
  360. //ajax处理
  361. }
  362. //添加新增按钮
  363. var newCount = 1;
  364. function addHoverDom(treeId, treeNode){
  365. var sObj = $("#" + treeNode.tId + "_span");
  366. if (treeNode.editNameFlag || $("#addBtn_" + treeNode.id).length > 0) return;
  367. var addStr = "<span class='zbutton add' id='addBtn_" + treeNode.id + "' title='添加' onfocus='this.blur();'></span>";
  368. sObj.append(addStr);
  369. var btn = $("#addBtn_" + treeNode.id);
  370. if (btn){
  371. btn.bind("click", function(){
  372. var treeContainer=$("#customSelectTree ul[class=ztree]");
  373. var zTree = $.fn.zTree.getZTreeObj(treeContainer.attr("id"));
  374. var newNode = zTree.addNodes(treeNode, {
  375. id: 100 + newCount,
  376. parentId: treeNode.id,
  377. name:"新增" + newCount++
  378. });
  379. //ajax处理
  380. if (newNode) {
  381. zTree.editName(newNode[0]);
  382. }
  383. return false;
  384. });
  385. }
  386. }
  387. function removeHoverDom(treeId, treeNode) {
  388. $("#addBtn_"+treeNode.id).unbind().remove();
  389. };
  390. </script>
  391. </body>
  392. </html>