test.php 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <title>Fixed Columns</title>
  5. <meta charset="utf-8">
  6. <link rel="stylesheet" href="http://www.kiivokms.net/css/bootstrap.min.css">
  7. <script src="http://www.kiivokms.net/assets/d5ce4d4c/libs/jquery/jquery-3.7.0.min.js"></script>
  8. <script src="http://www.kiivokms.net/assets/d5ce4d4c/libs/bootstrap/js/bootstrap.bundle.min.js"></script>
  9. <link href="https://unpkg.com/bootstrap-table@1.20.2/dist/bootstrap-table.min.css" rel="stylesheet">
  10. <script src="https://unpkg.com/bootstrap-table@1.20.2/dist/bootstrap-table.min.js"></script>
  11. <link href="https://unpkg.com/bootstrap-table@1.20.2/dist/extensions/fixed-columns/bootstrap-table-fixed-columns.min.css" rel="stylesheet">
  12. <script src="https://unpkg.com/bootstrap-table@1.20.2/dist/extensions/fixed-columns/bootstrap-table-fixed-columns.min.js"></script>
  13. </head>
  14. <body>
  15. <div class="container">
  16. <h1>Fixed Columns</h1>
  17. <div class="toolbar form-inline">
  18. <span>Fixed Number: </span>
  19. <input class="form-control" id="fixedNumber" type="number" value="1" min="1" max="5">
  20. </div>
  21. <table id="table" data-height="400" data-show-columns="true"></table>
  22. </div>
  23. <script>
  24. var $table = $('#table');
  25. $(function () {
  26. buildTable($table, 20, 20);
  27. $('#fixedNumber').change(function () {
  28. buildTable($table, 20, 20);
  29. });
  30. });
  31. function buildTable($el, cells, rows) {
  32. var i, j, row,
  33. columns = [],
  34. data = [];
  35. for (i = 0; i < cells; i++) {
  36. columns.push({
  37. field: 'field' + i,
  38. title: 'Cell' + i,
  39. sortable: true
  40. });
  41. }
  42. for (i = 0; i < rows; i++) {
  43. row = {};
  44. for (j = 0; j < cells; j++) {
  45. row['field' + j] = 'Rows-' + i + '-' + j;
  46. }
  47. data.push(row);
  48. }
  49. $el.bootstrapTable('destroy').bootstrapTable({
  50. columns: columns,
  51. data: data,
  52. search: true,
  53. toolbar: '.toolbar',
  54. fixedColumns: true,
  55. fixedNumber: +$('#fixedNumber').val()
  56. });
  57. }
  58. </script>
  59. </body>
  60. </html>