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

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

chrome

opera

ff

不使用对方css

/*-------------------------------------
zTree Style

version:	3.4
author:		Hunter.z
email:		[email protected]
website:	http://code.google.com/p/jquerytree/

-------------------------------------*/
.ztree .clear:after{ content:"."; display:block; height:0; clear:both; visibility:hidden; }
.ztree .clear{ zoom:1; }
.ztree .fleft{float:left; }
.ztree .fright{float:right; }
.ztree li{vertical-align:bottom/*ie7 bug*/;}
.ztree,.ztree ul,.ztree li{padding: 0px;margin: 0px;display: block;width: 100%;}
.ztree table{border-collapse:collapse;width:100%;border-spacing:0;border: 1px solid #bcbcbc;}
.ztree .tableA{display: block;width: 100%;color: black;text-decoration:none;cursor: default;}
.ztree .tableA:hover{background-color: #fafafa;}
.ztree a.tableA:focus {outline:none!important;}
.ztree table td{text-align:center;padding: 10px;}
.ztree .td1{width:40%;}
.ztree td.cline{border-left: 1px solid #bcbcbc;border-right: 1px solid #bcbcbc;}
.ztree .td2{width:10%;}
.ztree .td3{width:10%;}
.ztree .td4{width:10%;}
.ztree .td5{width:10%;}
.ztree .td6{width:10%;}
.ztree .td7{width:10%;}
.ztree .ztitle td{background-color: #fafafa;height: 40px;}
.ztree .ztitle .td1 .box{position: relative;width: 100%;height: 100%;}
.ztree .ztitle .td1 .plb{position: absolute;left:40px;bottom: 0px;white-space: nowrap;}
.ztree .ztitle .td1 .ptr{position: absolute;right:40px;top: 0px;white-space: nowrap;}
.ztree .data {border-top:0px none;}
.ztree .data .td1{text-align: left;}
.ztree .data .break{white-space: normal;word-wrap: break-word;word-break: break-all;}
.ztree .data .switch{cursor: pointer; text-align:left;}
.ztree .data .switch{background:no-repeat 10px center; padding-left: 25px; }
.ztree .data .center_open{background-image:url(./img/show.png); }
.ztree .data .center_close {background-image:url(./img/hide.png); }
.ztree .data .center_docu {background-image:url(./img/child.png); }

html代码

    <!DOCTYPE html>
    <html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <title>主动流失率</title>
        <script src="static/sea-modules/seajs/seajs/2.3.0/sea.js"></script>
        <script src="static/sea-modules/seajs/seajs-css.js"></script>
        <script>
            seajs.config({
                base:'./static/sea-modules/',
                alias: {
                  "$": "jquery/jquery-ext/1.0.0/jquery-ext.js"
              }
          });
        </script>
        <style type="text/css">

         .test{width:200px;}
     </style>
 </head>

 <body>
<ul class="ztree">
	<li>
	    <a class="tableA"  href="javascript:void(0);"><table class="ztitle">
		    <tr>
			    <td class="td1"><div class="box"><div class="plb">姓名</div><div class="ptr">信息</div></div></td>
			    <td class="td2 cline">所在单位</td>
			    <td class="td3">岗位</td>
			    <td class="td4 cline">上次九宫格位置</td>
			    <td class="td5">360測评排名</td>
			    <td class="td6 cline">直接下属</td>
			    <td class="td7">直接汇报人数</td>
		    </tr>
	    </table>
	    </a>
    </li>
</ul>
<ul id="tree" class="ztree zdata"></ul>
<script type="text/tpl" id="ztreeTPL">
	    <a class="tableA" href="javascript:void(0);"><table class="data">
		    <tr>
			    <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>
			    <td class="td2 cline break">所在单位</td>
			    <td class="td3 break">{{this.constructor}}</td>
			    <td class="td4 cline break">上次九宫格位置</td>
			    <td class="td5 break">{{this.constructor}}</td>
			    <td class="td6 cline break">直接下属</td>
			    <td class="td7 break">{{this.constructor}}</td>
		    </tr>
	    </table>
	    </a>
</script>

<script type = "text/javascript" >
seajs.use(['jquery/zTree/3.0.0/main','gallery/handlebars/1.0.2/handlebars'],function($,tpl){
        var zNodes =[
            {
                name:'',
                children: [
                    { name:''},
                    { name:'',
                        children: [
                            { name:''},
                            { name:''}
                        ]},
                    { name:'', isParent:true}
                ]
            },
            { name:''},
            { name:'',isParent:true}

        ];

        var setting = {
            view:{
                addDiyDom: function(rootId,nodeObj) {
                	console.log(arguments);
		            nodeObj.marginLeft = 20 * nodeObj.level;
		            var html = $('#ztreeTPL').html();
		            html = tpl.compile(html)(nodeObj);
		            $("#" + nodeObj.tId).html(html);
		        },
                showIcon:0,
                showTitle:0,
                showLine:0,
                selectedMulti:0,
                txtSelectedEnable:0
            }
        };
        $.fn.zTree.init($("#tree"), setting, zNodes);
});
</script>
</body>
</html>
时间: 2024-08-01 10:46:29

使用zTree控件制作的表格形式的树形+数据菜单的相关文章

jQuery控件简易日历表格

jQuery控件简易日历表格代码,jquery表格,jquery插件 ,jquery,日期,时间,日历表格,表格代码,jQuery控件简易日历表格代码是一款较为简单的显示日历的代码,兼容firefox,chrome,ie. 下载地址:http://www.huiyi8.com/sc/6362.html(转载请注明此处)

C#使用splitContainer控件制作收缩展开面板

C#使用splitContainer控件制作收缩展开面板 原创 2011年07月19日 17:18:02 标签: c# / object / 扩展 / 测试 15690 最近对Squid Ink公司的一款PC端软件系统上的一个收缩伸展面板很感兴趣,加上自己做的喷码机数据管理系统的界面非常单调,想在现在界面的基础上将这个功能加上去.我个人只是写c#的一个菜鸟,在网上查了C#的很多控件,很多人都是用GroupBox和SplitContainer实现的,于是就对这两个控件进行了测试.附Squid In

[iOS基础控件 - 6.6.1] 展示团购数据代码[iOS基础控件 - 6.7] 微博展示 使用代码自定义TableCell(动态尺寸)

A.需求 1.类似于微博内容的展示 2.头像 3.名字 4.会员标志 5.内容 6.分割线 7.配图(可选,可有可无) B.思路.步骤 1.Controller:UITableViewController 改变控制器继承自UITableViewController,storyboard中也同时使用新的TableViewController,其TableView作为启动入口. 2.View:代码自定义cell 使用代码组装每个cell,动态改变控件的位置.尺寸 cell含有一个WeiboFrame

重新想象 Windows 8.1 Store Apps (80) - 控件增强: WebView 之基本应用, POST 数据, 与 JavaScript 交互

[源码下载] 作者:webabcd 介绍重新想象 Windows 8.1 Store Apps 之控件增强 WebView 的基本应用 WebView 通过 POST 请求和 HTTP 头加载 url WebView 与 JavaScript 交互 示例1.演示 WebView 的基本应用WebView/Demo.xaml <Page x:Class="Windows81.Controls.WebView.Demo" xmlns="http://schemas.micr

easyui 中Datagrid 控件在列较多且无数据时,列显示不全的解决方案

在onLoadSuccess 中加入如下代码就OK啦 $('#dg3').datagrid({ onLoadSuccess:function(data){ if(data.total==0){ var dc = $(this).data('datagrid').dc; var header2Row = dc.header2.find('tr.datagrid-header-row'); dc.body2.find('table').append(header2Row.clone().css({"

web表格控件制作圆环图

工具/原料 web表格控件:FineReport7.1.1 大小:148.2M 适用平台:windows/linux 1. 描述 圆环图类似于饼图,显示个体与整体之间的关系,可以直观了解个体部分所占整体部分的百分比,但是不同于饼图的是,圆环图可以包含多个分类,即多层圆环图,可以从圆环的径向上去比较不同分类下同一系列的数据的变化趋势. 2. 示例 下面我们制作一张圆环图图表,显示各个地区产品的销量情况,在查看每个地区产品销量所在份额的同时,对比同一个产品在不同地区的销量差异情况. 2.1 数据准备

网页WEB打印控件制作-开放源码

在WEB系统中,打印的确是比较烦人的问题,如果我们能制作一个属于自己的自定义的打印插件,那么我们在后续自定义打印的时候能随心所欲的控制打印,这样的效果对于程序员来说是非常开心的一件事件,本文将自己开发编写的C# 制作的HTML打印插件分享出来,让有同样需求的朋友提供一个参考:此插件是基于Microsoft .NET Framework 2.0 开发的,缺点是每台客户端在安装插件时,必须要安装Microsoft .NET Framework 2.0 :本插件能实现 页眉.页脚.表头.标题.表尾的分

网页WEB打印控件制作 开放源码可以调试

在WEB系统中,打印的确是比较烦人的问题,如果我们能制作一个属于自己的自定义的打印插件,那么我们在后续自定义打印的时候能随心所欲的控制打印,这样的效果对于程序员来说是非常开心的一件事件,本文将自己开发编写的C# 制作的HTML打印插件分享出来,让有同样需求的朋友提供一个参考:此插件是基于Microsoft .NET Framework 2.0 开发的,缺点是每台客户端在安装插件时,必须要安装Microsoft .NET Framework 2.0 :本插件能实现 页眉.页脚.表头.标题.表尾的分

网页WEB打印控件制作

在WEB系统中,打印的确是比较烦人的问题,如果我们能制作一个属于自己的自定义的打印插件,那么我们在后续自定义打印的时候能随心所欲的控制打印,这样的效果对于程序员来说是非常开心的一件事件,本文将自己开发编写的C# 制作的HTML打印插件分享出来,让有同样需求的朋友提供一个参考:此插件是基于Microsoft .NET Framework 2.0 开发的,缺点是每台客户端在安装插件时,必须要安装Microsoft .NET Framework 2.0 :本插件能实现 页眉.页脚.表头.标题.表尾的分