| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586 |
- <!DOCTYPE html>
- <html lang="en">
- <head>
- <meta charset="utf-8">
- <title>Test · Bootstrap Table</title>
- <meta name="author" content="zhixin">
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
- <link rel="stylesheet" href="assets/bootstrap/css/bootstrap.min.css">
- <!--<link rel="stylesheet" href="assets/bootstrap2.3/css/bootstrap.min.css">-->
- <!--<link rel="stylesheet" href="assets/bootstrap2.3/css/bootstrap-responsive.min.css">-->
- <link rel="stylesheet" href="../src/bootstrap-table.css">
- </head>
- <body>
- <div class="container">
- <div>
- <label>Cells: </label><input id="cells" type="text" placeholder="Cells" value="5">
- <label>Rows: </label><input id="rows" type="text" placeholder="Rows" value="100">
- <button id="build" class="btn btn-default">Build</button>
- </div>
- <table id="table"
- data-toggle="table"
- data-url="data1.json"
- data-show-columns="true"
- data-search="true"
- data-show-refresh="true"
- data-show-toggle="true"
- data-pagination="true"
- data-height="500">
- <thead>
- <tr>
- <th data-field="id" data-formatter="idFormatter">ID</th>
- <th data-field="name">Item Name</th>
- <th data-field="price">Item Price</th>
- </tr>
- </thead>
- </table>
- </div>
- <script src="assets/jquery.min.js"></script>
- <script src="assets/bootstrap/js/bootstrap.min.js"></script>
- <!--<script src="assets/bootstrap2.3/js/bootstrap.min.js"></script>-->
- <script src="assets/table-export/tableExport.js"></script>
- <script src="assets/table-export/jquery.base64.js"></script>
- <script src="../src/bootstrap-table.js"></script>
- <script src="../src/extensions/export/bootstrap-table-export.js"></script>
- <script>
- $(function () {
- $('#build').click(build);//.trigger('click');
- $('#cells, #rows').keyup(function (e) {
- if (e.keyCode === 13) {
- build();
- }
- });
- });
- function build() {
- var cells = $('#cells').val(),
- rows = $('#rows').val(),
- i, j, row,
- columns = [],
- data = [];
- for (i = 0; i < cells; i++) {
- columns.push({
- field: 'field' + i,
- title: 'Cell' + i
- });
- }
- for (i = 0; i < rows; i++) {
- row = {};
- for (j = 0; j < cells; j++) {
- row['field' + j] = 'Row-' + i + '-' + j;
- }
- data.push(row);
- }
- $('#table').bootstrapTable('destroy').bootstrapTable({
- columns: columns,
- data: data
- });
- }
- function idFormatter(value) {
- return value + 100;
- }
- </script>
- </body>
- </html>
|