bootstrap-table--学习-----折叠效果

折叠效果图如下

哈哈哈,代码如下:

<!doctype html>
<html lang="zh">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"> 
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link href="css/bootstrap.min.css" rel="stylesheet">
    <link rel="stylesheet" href="css/bootstrap-table-expandable.css">
    <script src="js/jquery-1.11.0.min.js" type="text/javascript"></script>
    <script src="js/bootstrap.min.js"></script>
    <script src="js/bootstrap-table-expandable.js"></script>
</head>
<body>
    <div class="htmleaf-container">
        
        <div class="container">
            <div class="table-responsive">
                                <table style="word-break:break-all; word-wrap:break-all;" class="table table-hover table-expandable">
                                    <thead>
                                        <tr>
                                            <th>单号</th>
                                            <th>派送人</th>
                                            <th>收货人</th>
                                            <th>操作</th>
                                        </tr>
                                    </thead>
                                    <tbody role="alert" aria-live="polite" aria-relevant="all">
                                         <tr class="even">
                                                <td class="">62345678</td>
                                                <td class="">1111</td>
                                                <td class="">1111</td>
                                                <td class="">详情</td>
                                          </tr>
                                          <tr>
                                                <td colspan="5">
                                                   哈哈哈哈测试与
                                                 </td>                                          
                                           </tr>
                                           <tr class="even">
                                                <td class="">201203814</td>
                                                <td class="">2222</td>
                                                <td class="">2222</td>
                                                <td class="">详情</td>
                                            </tr>
                                            <tr>
                                                <td colspan="5">
                                                      <div class="tabbable">
                                                        <ul class="nav nav-tabs" id="myTab">
                                                            <li class="active"><a data-toggle="tab"
                                                                href="#home"> 
                                                                <i class="green icon-home bigger-110"></i> 发货单信息
                                                            </a></li>
                                                            <li><a data-toggle="tab"
                                                                href="#records">
                                                                    <i class="green icon-comment bigger-110"></i> 商品详情
                                                            </a></li>
                                                        </ul>
                                                        <div class="tab-content">
                                            
                                                        </div>
                                                    </div>
                                                     <div id="home" class="tab-pane in active">
                                                                <div class="profile-user-info profile-user-info-striped">
                                                                
                                                                    <div class="profile-info-row"
                                                                        style="display: -webkit-box;height: 35px;">
                                                                        <div class="profile-info-name">
                                                                            <span>单号:</span>
                                                                        </div>
                                                                        <div class="profile-info-value" style="width:20%">
                                                                            <span class="editable"> &nbsp;
                                                                                hhhhh</span>
                                                                        </div>
                                                                        
                                                                    </div>
                                                                </div>
                                                                <div class="hr dotted"></div>
                                                                </br>
                                                               </div>
                                                       </div>    
                                                      
                                                    </div>
                                                 </td>                                          

                                            </tr>
                                   </tbody>
                                 </table>

              </div>
        </div>
    </div>
</body>
</html>

Bootstrap Table Treegrid 是基于 Bootstrap Table 的扩展插件,用于在表格中显示树形结构数据。下面是使用 Bootstrap Table Treegrid 的步骤: 1. 引入必要的文件 ``` <link rel="stylesheet" href="https://cdn.staticfile.org/bootstrap/3.3.7/css/bootstrap.min.css"> <link rel="stylesheet" href="https://cdn.staticfile.org/bootstrap-table/1.15.4/bootstrap-table.min.css"> <link rel="stylesheet" href="https://cdn.staticfile.org/bootstrap-table-treegrid/1.11.0/bootstrap-table-treegrid.min.css"> <script src="https://cdn.staticfile.org/jquery/3.5.1/jquery.min.js"></script> <script src="https://cdn.staticfile.org/bootstrap/3.3.7/js/bootstrap.min.js"></script> <script src="https://cdn.staticfile.org/bootstrap-table/1.15.4/bootstrap-table.min.js"></script> <script src="https://cdn.staticfile.org/bootstrap-table-treegrid/1.11.0/bootstrap-table-treegrid.min.js"></script> ``` 2. 在 HTML 页面中添加表格元素,并设置 data-url 属性为数据源的 URL。例如: ``` <table id="treegrid" data-url="data.json"></table> ``` 3. 在 JavaScript 中初始化表格,启用 Treegrid 插件。例如: ``` $('#treegrid').bootstrapTable({ columns: [{ field: 'id', title: 'ID' }, { field: 'name', title: '名称' }, { field: 'parentId', title: '父级ID' }], treeShowField: 'name', // 指定树形结构显示的字段 parentIdField: 'parentId', // 指定父级ID字段 idField: 'id', // 指定ID字段 treeCollapse: false, // 是否默认折叠树形结构 treeGrid: true, // 启用 Treegrid 插件 expandIcon: 'glyphicon glyphicon-plus', // 展开图标 collapseIcon: 'glyphicon glyphicon-minus' // 折叠图标 }); ``` 4. 数据源的格式需要满足以下要求: * 每个节点需要有一个 ID 字段和一个父级 ID 字段。 * 根节点的父级 ID 字段可以为空。 * 节点之间的层级关系可以通过父级 ID 字段来确定。 以上就是使用 Bootstrap Table Treegrid 的基本步骤,您可以根据实际情况调整参数和数据源格式。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值