帝国模板之家为广大用户提供专业、一站式建站服务。

网页特效

网页特效栏目收集了最全最新的前端网页插件,包括最流行的jQuery,Bootstrap,Js,Css,Vue等主流特效插件。

当前位置:首页 > 资源 > 网页特效 > 正文

可折叠/可扩展的jQuery表格树插件

帝国模板之家 2020-12-09 网页特效 评论

插件介绍

这是一款轻量级jQuery树表视图插件,将对象数组中定义的层次结构数据转换为一个可折叠/可扩展的表格树视图。

使用方法

1. 在页面中添加表格树插件文件。

<link rel="stylesheet" href="./css/tree-table.css" />

2. 在页面中创建一个空的HTML表。

<div class="tree-table-wrap">
  <table class="tree-table">
    <thead>
      <tr>
        <th>Column 1</th>
        <th>Column 2</th>
        <th>Column 3</th>
        <th>Column 4</th>
        <th>Column 5</th>
      </tr>
    </thead>
    <tbody id="table-tree">
    </tbody>
  </table>
</div>

3. 在对象数组中定义分层数据,如下所示:

var items = [
        {
            id: 1,
            priority: 1,
            from: '463587341@qq.com',
            subject: '帝国模板之家',
            sentDate: '2020-12-09'
        },
        {
            id: 2,
            priority: 2,
            from: '463587341@qq.com',
            subject: 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX',
            sentDate: '2020-12-09',
            parentId: 1
        },
        {
            id: 3,
            priority: 3,
            from: '463587341@qq.com',
            subject: 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX',
            sentDate: '2020-12-09',
            parentId: 1
        },
        {
            id: 4,
            priority: 4,
            from: '463587341@qq.com',
            subject: 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX',
            sentDate: '2020-12-09',
            parentId: 3
        },
        {
            id: 5,
            priority: 5,
            from: '463587341@qq.com',
            subject: 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX',
            sentDate: '2020-12-09'
        },
        {
            id: 6,
            priority: 6,
            from: '463587341@qq.com',
            subject: 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX',
            sentDate: '2020-12-09'
        },
        {
            id: 7,
            priority: 7,
            from: '463587341@qq.com',
            subject: 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX',
            sentDate: '2020-12-09',
            parentId: 3
        },
        {
            id: 8,
            priority: 8,
            from: '463587341@qq.com',
            subject: 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX',
            sentDate: '2020-12-09',
            parentId: 3
        },
        {
            id: 9,
            priority: 9,
            from: '463587341@qq.com',
            subject: 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX',
            sentDate: '2020-12-09',
            parentId: 3
        },
        {
            id: 10,
            priority: 10,
            from: '463587341@qq.com',
            subject: 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX',
            sentDate: '2020-12-09',
            parentId: 8
        },
        {
            id: 11,
            priority: 11,
            from: '463587341@qq.com',
            subject: 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX',
            sentDate: '2020-12-09',
            parentId: 8
        },
        {
            id: 12,
            priority: 12,
            from: '463587341@qq.com',
            subject: 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX',
            sentDate: '2020-12-09',
            parentId: 10
        },
        {
            id: 13,
            priority: 13,
            from: '463587341@qq.com',
            subject: 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX',
            sentDate: '2020-12-09',
            parentId: 5
        },
        {
            id: 17,
            priority: 13,
            from: '463587341@qq.com',
            subject: 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX',
            sentDate: '2020-12-09',
            parentId: 13
        },
        {
            id: 18,
            priority: 13,
            from: '463587341@qq.com',
            subject: 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX',
            sentDate: '2020-12-09',
            parentId: 13
        },
        {
            id: 19,
            priority: 13,
            from: '463587341@qq.com',
            subject: 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX',
            sentDate: '2020-12-09',
            parentId: 13
        },
        {
            id: 14,
            priority: 14,
            from: '463587341@qq.com',
            subject: 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX',
            sentDate: '2020-12-09',
            parentId: 5
        },
        {
            id: 15,
            priority: 14,
            from: '463587341@qq.com',
            subject: 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX',
            sentDate: '2020-12-09',
            parentId: 5
        },{
            id: 16,
            priority: 14,
            from: '463587341@qq.com',
            subject: 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX',
            sentDate: '2020-12-09',
            parentId: 5
        }];

4. 在页面尾部加载jQuery库和表格树插件文件。

<script src="/path/to/jquery.slim.min.js"></script>
<script src="/path/to/tree-table.js"></script>
人生不要怕失败,因为失败连着成功。只有那些有勇气的人,才敢不断挑战人生。

已有 位小伙伴发表了看法

欢迎 发表评论

  • 匿名发表

关于

帝国cms模板

网页插件

帝国模板之家 | www.moyouyouw.cn

本站所有模板/文章除标明原创外,均来自网络转载,版权归原作者所有,如果有侵犯到您的权益,请联系站长删除,谢谢! 寻找帝国cms模板首选帝国模板之家,用心做站,上线至今广受好评,值得信赖!

  • 交流群1:帝国cms交流群1
  • 交流群2:帝国cms交流群2
在线QQ 给我留言