BootstrapTable 表格插件

    BootStrap Table 下載:https://v3.bootcss.com/getting-started/javascript

    BootStrap Table Css:https://v3.bootcss.com/css/css

    BootStrap Table 組件:https://v3.bootcss.com/components/html

    

    附上一個BootStrapTablle的簡單例子:html5

   效果:java

   

   目錄結構:jquery

    

    代碼:npm

<!DOCTYPE html>
<html lang="zh-CN">
  <head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <!-- 上述3個meta標籤*必須*放在最前面,任何其餘內容都*必須*跟隨其後! -->
    <title>Bootstrap 101 Template</title>

    <!-- Bootstrap -->
    <link href="css/bootstrap.min.css" rel="stylesheet">
    <link href="css/bootstrap-table.min.css" rel="stylesheet">

    <!-- HTML5 shim 和 Respond.js 是爲了讓 IE8 支持 HTML5 元素和媒體查詢(media queries)功能 -->
    <!-- 警告:經過 file:// 協議(就是直接將 html 頁面拖拽到瀏覽器中)訪問頁面時 Respond.js 不起做用 -->
    <!--[if lt IE 9]>
      <script src="https://cdn.jsdelivr.net/npm/html5shiv@3.7.3/dist/html5shiv.min.js"></script>
      <script src="https://cdn.jsdelivr.net/npm/respond.js@1.4.2/dest/respond.min.js"></script>
    <![endif]-->
    <style>
        #mytab  thead{background: #5488c4;}
        #mytab tr:nth-child(even){
            background:#f4f8fb;
        }
    </style>
  </head>
  <body>
          <table id="mytab" class="table table-hover"></table>
        <!-- jQuery (Bootstrap 的全部 JavaScript 插件都依賴 jQuery,因此必須放在前邊) -->
        <script src="js/jquery.min.js"></script>
        <!-- 加載 Bootstrap 的全部 JavaScript 插件。你也能夠根據須要只加載單個插件。 -->
        <script src="js/bootstrap.min.js"></script>
        <!-- 加載 Bootstrap-Table 插件 -->
        <script src="js/bootstrap-table.min.js"></script>
        <!-- 漢化插件 -->
        <script src="js/bootstrap-table-zh-CN.min.js"></script>
        <script type="application/javascript">
            $('#mytab').bootstrapTable({
                url: 'json/data.json',
                queryParams: "queryParams",
                toolbar: "#toolbar",
                sidePagination: "true",
                striped: true, // 是否顯示行間隔色
                search : "true",
                uniqueId: "ID",
                pageSize: "5",
                pagination: true, // 是否分頁
                sortable: true, // 是否啓用排序
                showToggle:true,
                columns: [{
                        field: 'id',
                        title: '登陸名'
                    },
                    {
                        field: 'name',
                        title: '暱稱'
                    },
                    {
                        field: 'price',
                        title: '角色'
                    },
                    {
                        field: 'price',
                        title: '操做',
                        width: 120,
                        align: 'center',
                        valign: 'middle',
                        formatter: actionFormatter,
                    },

                ]
            });
            //操做欄的格式化
            function actionFormatter(value, row, index) {
                var id = value;
                var result = "";
                result += "<a href='javascript:;' class='btn btn-xs blue' onclick=\"EditViewById('" + id + "')\" title='編輯'><span class='glyphicon glyphicon-pencil'></span>編輯</a>";
                result += "<a href='javascript:;' class='btn btn-xs red' onclick=\"DeleteByIds('" + id + "')\" title='刪除'><span class='glyphicon glyphicon-remove'></span>刪除</a>";
                return result;
            }
        </script>
  </body>
</html>
相關文章
相關標籤/搜索