当前位置:   article > 正文

使用zTree控件制作的表格形式的树形+数据菜单_ztree table

ztree table


测试了一下,兼容ie7以上,

chrome

opera

ff



不使用对方css

  1. /*-------------------------------------
  2. zTree Style
  3. version: 3.4
  4. author: Hunter.z
  5. email: hunter.z@263.net
  6. website: http://code.google.com/p/jquerytree/
  7. -------------------------------------*/
  8. .ztree .clear:after{ content:"."; display:block; height:0; clear:both; visibility:hidden; }
  9. .ztree .clear{ zoom:1; }
  10. .ztree .fleft{float:left; }
  11. .ztree .fright{float:right; }
  12. .ztree li{vertical-align:bottom/*ie7 bug*/;}
  13. .ztree,.ztree ul,.ztree li{padding: 0px;margin: 0px;display: block;width: 100%;}
  14. .ztree table{border-collapse:collapse;width:100%;border-spacing:0;border: 1px solid #bcbcbc;}
  15. .ztree .tableA{display: block;width: 100%;color: black;text-decoration:none;cursor: default;}
  16. .ztree .tableA:hover{background-color: #fafafa;}
  17. .ztree a.tableA:focus {outline:none!important;}
  18. .ztree table td{text-align:center;padding: 10px;}
  19. .ztree .td1{width:40%;}
  20. .ztree td.cline{border-left: 1px solid #bcbcbc;border-right: 1px solid #bcbcbc;}
  21. .ztree .td2{width:10%;}
  22. .ztree .td3{width:10%;}
  23. .ztree .td4{width:10%;}
  24. .ztree .td5{width:10%;}
  25. .ztree .td6{width:10%;}
  26. .ztree .td7{width:10%;}
  27. .ztree .ztitle td{background-color: #fafafa;height: 40px;}
  28. .ztree .ztitle .td1 .box{position: relative;width: 100%;height: 100%;}
  29. .ztree .ztitle .td1 .plb{position: absolute;left:40px;bottom: 0px;white-space: nowrap;}
  30. .ztree .ztitle .td1 .ptr{position: absolute;right:40px;top: 0px;white-space: nowrap;}
  31. .ztree .data {border-top:0px none;}
  32. .ztree .data .td1{text-align: left;}
  33. .ztree .data .break{white-space: normal;word-wrap: break-word;word-break: break-all;}
  34. .ztree .data .switch{cursor: pointer; text-align:left;}
  35. .ztree .data .switch{background:no-repeat 10px center; padding-left: 25px; }
  36. .ztree .data .center_open{background-image:url(./img/show.png); }
  37. .ztree .data .center_close {background-image:url(./img/hide.png); }
  38. .ztree .data .center_docu {background-image:url(./img/child.png); }


html代码

  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  5. <title>主动流失率</title>
  6. <script src="static/sea-modules/seajs/seajs/2.3.0/sea.js"></script>
  7. <script src="static/sea-modules/seajs/seajs-css.js"></script>
  8. <script>
  9. seajs.config({
  10. base:'./static/sea-modules/',
  11. alias: {
  12. "$": "jquery/jquery-ext/1.0.0/jquery-ext.js"
  13. }
  14. });
  15. </script>
  16. <style type="text/css">
  17. .test{width:200px;}
  18. </style>
  19. </head>
  20. <body>
  21. <ul class="ztree">
  22. <li>
  23. <a class="tableA" href="javascript:void(0);"><table class="ztitle">
  24. <tr>
  25. <td class="td1"><div class="box"><div class="plb">姓名</div><div class="ptr">信息</div></div></td>
  26. <td class="td2 cline">所在单位</td>
  27. <td class="td3">岗位</td>
  28. <td class="td4 cline">上次九宫格位置</td>
  29. <td class="td5">360测评排名</td>
  30. <td class="td6 cline">直接下属</td>
  31. <td class="td7">直接汇报人数</td>
  32. </tr>
  33. </table>
  34. </a>
  35. </li>
  36. </ul>
  37. <ul id="tree" class="ztree zdata"></ul>
  38. <script type="text/tpl" id="ztreeTPL">
  39. <a class="tableA" href="javascript:void(0);"><table class="data">
  40. <tr>
  41. <td class="td1"><span style="margin-left:{{marginLeft}}px;" id="{{this.tId}}_switch" class="button level{{this.level}} switch {{#if this.isParent}}{{#if this.open}}center_open{{else}}center_close{{/if}}{{else}}center_docu{{/if}}" treenode_switch="">{{this.constructor}}</span></td>
  42. <td class="td2 cline break">所在单位</td>
  43. <td class="td3 break">{{this.constructor}}</td>
  44. <td class="td4 cline break">上次九宫格位置</td>
  45. <td class="td5 break">{{this.constructor}}</td>
  46. <td class="td6 cline break">直接下属</td>
  47. <td class="td7 break">{{this.constructor}}</td>
  48. </tr>
  49. </table>
  50. </a>
  51. </script>
  52. <script type = "text/javascript" >
  53. seajs.use(['jquery/zTree/3.0.0/main','gallery/handlebars/1.0.2/handlebars'],function($,tpl){
  54. var zNodes =[
  55. {
  56. name:'',
  57. children: [
  58. { name:''},
  59. { name:'',
  60. children: [
  61. { name:''},
  62. { name:''}
  63. ]},
  64. { name:'', isParent:true}
  65. ]
  66. },
  67. { name:''},
  68. { name:'',isParent:true}
  69. ];
  70. var setting = {
  71. view:{
  72. addDiyDom: function(rootId,nodeObj) {
  73. console.log(arguments);
  74. nodeObj.marginLeft = 20 * nodeObj.level;
  75. var html = $('#ztreeTPL').html();
  76. html = tpl.compile(html)(nodeObj);
  77. $("#" + nodeObj.tId).html(html);
  78. },
  79. showIcon:0,
  80. showTitle:0,
  81. showLine:0,
  82. selectedMulti:0,
  83. txtSelectedEnable:0
  84. }
  85. };
  86. $.fn.zTree.init($("#tree"), setting, zNodes);
  87. });
  88. </script>
  89. </body>
  90. </html>


声明:本文内容由网友自发贡献,转载请注明出处:【wpsshop】
推荐阅读
相关标签
  

闽ICP备14008679号