index.html 5.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="utf-8" />
  5. <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
  6. <title>bootstrap-table demo</title>
  7. <meta name="author" content="zhixin" />
  8. <link rel="stylesheet" href="/css/bootstrap.css" />
  9. <link rel="stylesheet" href="/css/fork.css" />
  10. </head>
  11. <body>
  12. <div class="container">
  13. <h3>Table Properties:</h3>
  14. <table id="table"></table>
  15. <h3>Column Properties:</h3>
  16. <table id="column"></table>
  17. <h3>Events:</h3>
  18. <table id="event"></table>
  19. <h3>Methods:</h3>
  20. <table id="method"></table>
  21. </div>
  22. <a href="https://github.com/wenzhixin/bootstrap-table" class="fork_me"></a>
  23. <script type="text/javascript" src="/js/jquery-1.8.3.min.js"></script>
  24. <script type="text/javascript" src="jquery.bootstrap.table.js"></script>
  25. <script type="text/javascript">
  26. $(function() {
  27. $('#table').bootstrapTable({
  28. columns: [
  29. {field: 'name', title: 'Name', align: 'center', width: 60, sortable: true},
  30. {field: 'type', title: 'Type', align: 'center', width: 60},
  31. {field: 'description', title: 'Description', width: 400},
  32. {field: 'default', title: 'Default', align: 'right', width: 180}
  33. ],
  34. data: [
  35. {name: 'sortName', type: 'String', description: 'Defines which column can be sorted.', 'default': 'undefined'},
  36. {name: 'sortOrder', type: 'String', description: 'Defines the column sort order, can only be "asc" or "desc".', 'default': 'asc'},
  37. {name: 'className', type: 'String', description: 'The table class name', 'default': 'table table-bordered table-hover'},
  38. {name: 'columns', type: 'Array', description: 'The table columns config object, see column properties for more details.', 'default': '[]'},
  39. {name: 'data', type: 'Array', description: 'The data to be loaded.', 'default': '[]'}
  40. ]
  41. });
  42. $('#column').bootstrapTable({
  43. sortName: 'name',
  44. sortOrder: 'asc',
  45. columns: [
  46. {field: 'name', title: 'Name', align: 'center', width: 60, sortable: true},
  47. {field: 'type', title: 'Type', align: 'center', width: 60},
  48. {field: 'description', title: 'Description', width: 400},
  49. {field: 'default', title: 'Default', align: 'right', width: 180}
  50. ],
  51. data: [
  52. {name: 'field', type: 'String', description: 'The column field name.', 'default': 'undefined'},
  53. {name: 'title', type: 'String', description: 'The column title text.', 'default': 'undefined'},
  54. {name: 'align', type: 'String', description: 'Indicate how to align the column data. "left", "right", "center" can be used.', 'default': 'undefined'},
  55. {name: 'width', type: 'Number', description: 'The width of column. If not defined, the width will auto expand to fit its contents.', 'default': 'undefined'},
  56. {name: 'sortable', type: 'Boolean', description: 'True to allow the column can be sorted.', 'default': 'false'},
  57. {name: 'order', type: 'String', description: 'The default sort order, can only be "asc" or "desc".', 'default': 'asc'},
  58. {name: 'formatter', type: 'Function', description: 'The cell formatter function, take two parameters: <br />value: the field value. <br />row: the row record data.', 'default': 'undefined'},
  59. {name: 'sorter', type: 'Function', description: 'The custom field sort function that used to do local sorting, take two parameters: <br />a: the first field value.<br /> b: the second field value.', 'default': 'undefined'}
  60. ]
  61. });
  62. $('#event').bootstrapTable({
  63. columns: [
  64. {field: 'name', title: 'Name', align: 'center', width: 100, sortable: true},
  65. {field: 'parameter', title: 'Parameter', align: 'center', width: 100, sortable: true},
  66. {field: 'description', title: 'Description', width: 400, sortable: true}
  67. ],
  68. data: [
  69. {name: 'onClickRow', parameter: 'row', description: 'Fires when user click a row, the parameters contains: <br />row: the record corresponding to the clicked row'},
  70. {name: 'onSort', parameter: 'name, order', description: 'Fires when user sort a column, the parameters contains: <br />name: the sort column field name<br />order: the sort column order'}
  71. ],
  72. onClickRow: function(row) {
  73. console.log(row);
  74. },
  75. onSort: function(name, order) {
  76. console.log(name, order);
  77. }
  78. });
  79. $('#method').bootstrapTable({
  80. columns: [
  81. {field: 'name', title: 'Name', align: 'center', width: 100},
  82. {field: 'parameter', title: 'Parameter', align: 'center', width: 100},
  83. {field: 'description', title: 'Description', width: 400}
  84. ]
  85. }).bootstrapTable('load', [
  86. {name: 'load', parameter: 'data', description: 'Load the data to table.'}
  87. ]).bootstrapTable('append', [
  88. {name: 'append', parameter: 'data', description: 'Append the data to table.'}
  89. ]);
  90. });
  91. </script>
  92. <script type="text/javascript" src="/js/analytics.js"></script>
  93. </body>
  94. </html>