bootstrap-table相关

bootstrap-table官方文档

各种bootstrap-table资源文件下载

使用方法参考(其实也就是介绍了部分官方文档的方法,官方文档很多都写到了,但是没有很详细,所以我每次要看了别人的用法再反过来看官方文档才恍然大悟,原来文档里都写了):【Bootstrap】 bootstrap-table表格组件


通过Data属性的方式,无需编写JavaScript启用bootstrap table, 设置data-toggle="table"即可,同理,如果相以js方式启用bootstrap table,那就不要设置data-toggle="table"!


bootstrap-table给表格添加复选框,可以通过html方式(必须给checkbox留dom位置),或者js方式

<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <link rel="stylesheet" href="css/bootstrap.min.css">
    <link rel="stylesheet" href="css/bootstrap-table.min.css">

</head>

<body>
    <!-- <table id="table"></table> -->
    <table class="table table-bordered table-hover" id="table">
        <thead>
            <tr>
                <th></th>
                <th>Item ID</th>
                <th>Item Name</th>
                <th>Item Price</th>
            </tr>
        </thead>
        <tbody>
            <tr>
                <td></td>
                <td>1</td>
                <td>Item 1</td>
                <td>$1</td>
            </tr>
            <tr>
                <td></td>
                <td>2</td>
                <td>Item 2</td>
                <td>$2</td>
            </tr>
        </tbody>
    </table>
    <script src="js/jquery-1.11.2.min.js"></script>
    <script src="js/bootstrap.min.js"></script>
    <script src="js/bootstrap-table.min.js"></script>
    <script>
        $('#table').bootstrapTable({
            pagination: true,
            sidePagination: "client", //分页方式:client客户端分页,server服务端分页(*)
            pageNumber: 1, //初始化加载第一页,默认第一页,并记录
            pageSize: 5,
            clickToSelect: true,
            maintainSelected: true, // 带分页的话可以保持其他页选中的
            columns: [{
                checkbox: true
            }]
        });

        // 纯js方法
        // $('#table').bootstrapTable({
        //     columns: [{
        //         checkbox: true
        //     }, {
        //         field: 'id',
        //         title: 'Item ID'
        //     }, {
        //         field: 'name',
        //         title: 'Item Name'
        //     }, {
        //         field: 'price',
        //         title: 'Item Price'
        //     }],
        //     data: [{
        //         id: 1,
        //         name: 'Item 1',
        //         price: '$1'
        //     }, {
        //         id: 2,
        //         name: 'Item 2',
        //         price: '$2'
        //     }]
        // });
    </script>
</body>

</html>

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值