bootstrap table小案例,bootstraptable

來源:互聯網
上載者:User

bootstrap table小案例,bootstraptable

Bootstrap Table是基於Bootstrap的輕量級表格外掛程式,只需要簡單的配置就可以實現強大的支援固定表頭、單複選、排序、分頁、搜尋以及自訂表格頭等功能。

1、所需要的庫:

    bootstrap.min.css

    bootstrap-table.css

    jquery.min.js

    bootstrap.min.js

    bootstrap-table.js

2、Bootstrap Table擷取資料的方式:

    Bootstrap Table通過data屬性標籤或者JavaScript來顯示表格式資料:

(1)、通過data屬性標籤

 在表格中設定data-toggle=“table”,此方式可以在不寫JavaScript的情況下啟用Bootstrap Table。

<table data-toggle="table" data-url="data.json">  <thead>    ...  </thead></table>

(2)、通過JavaScipt向表格傳入資料:

<table id="table"></table>      <1>、簡單的待用資料        $('#table').bootstrapTable({                  columns: [{            field: 'id',            title: 'Item ID'          }, {            field: 'username',            title: 'Item Username'          }, {            field: 'password',            title: 'Item Passowrd'          }],          data: [{            id: 1,            username: 'Item 1',            passowrd: '$1'          }, {            id: 2,            username: 'Item 2',            password: '$2'          }]});           <2>、通過url擷取資料        $('#table').bootstrapTable({                  url: 'data1.json',          columns: [{            field: 'id',            title: 'Item ID'          }, {            field: 'username',            title: 'Item Username'          }, {            field: 'passowrd',            title: 'Item Passowrd'          }, ]});

3、Bootstrap Table簡單的demo:

<!doctype html><html>  <head>      <meta charset="utf-8">        <title>Bootstrap Table的demo</title>        <link rel="stylesheet" href="bootstrap.css">        <link rel="stylesheet" href="bootstrap-table.css">    </head>  <body> <table id="table"></table><!--引入相關的js檔案--> <script src="jquery.min.js"></script> <script src="bootstrap.js"></script> <script src="bootstrap-table.js"></script>   <!--自訂javaScript--> <script>   $('#table').bootstrapTable({    columns: [{      field: 'id',      title: 'Item ID'      }, {      field: 'username',      title: 'Item Username'      }, {      field: 'passsword',      title: 'Item Password'    }],    data: [{      id: 1,      username: 'Item 1',      passowrd: '123'      }, {      id: 2,      username: 'Item 2',      passowrd: '123      }]   }); </script></body></html>

以上就是本文的全部內容,希望對大家的學習有所協助,也希望大家多多支援幫客之家。

如果大家還想深入學習,可以點擊這裡進行學習,再為大家附兩個精彩的專題:Bootstrap學習教程 Bootstrap實戰教程

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.