index.html 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="utf-8" />
  5. <title>Bootstrap Table</title>
  6. <meta name="author" content="zhixin" />
  7. <meta name="viewport" content="width=device-width; initial-scale=1.0" />
  8. <link rel="stylesheet" href="//wenzhixin.net.cn/css/bootstrap.css" />
  9. <link rel="stylesheet" href="//wenzhixin.net.cn/css/bootstrap-responsive.min.css" />
  10. <link rel="stylesheet" href="//wenzhixin.net.cn/css/docs.css" />
  11. <link rel="stylesheet" href="//wenzhixin.net.cn/css/fork.css" />
  12. <link rel="stylesheet" href="bootstrap-table.css" />
  13. <!--[if lt IE 9]>
  14. <script src="//wenzhixin.net.cn/js/html5shiv.js"></script>
  15. <script src="//wenzhixin.net.cn/js/respond.min.js"></script>
  16. <![endif]-->
  17. <style>
  18. body {
  19. padding-bottom: 60px;
  20. }
  21. </style>
  22. </head>
  23. <body data-spy="scroll" data-target=".bs-docs-sidebar">
  24. <div class="navbar navbar-fixed-top">
  25. <div class="navbar-inner">
  26. <div class="container">
  27. <a class="brand" href="#">
  28. Bootstrap Table
  29. </a>
  30. </div>
  31. </div>
  32. </div>
  33. <div class="container">
  34. <div class="row">
  35. <div class="span3 bs-docs-sidebar">
  36. <ul class="nav nav-list bs-docs-sidenav affix" data-spy="affix">
  37. <li><a href="#properties"><i class="icon-chevron-right"></i> Table Properties</a></li>
  38. <li><a href="#columns"><i class="icon-chevron-right"></i> Column Properties</a></li>
  39. <li><a href="#events"><i class="icon-chevron-right"></i> Events</a></li>
  40. <li><a href="#methods"><i class="icon-chevron-right"></i> Methods</a></li>
  41. <li><a href="#examples"><i class="icon-chevron-right"></i> Examples</a></li>
  42. </ul>
  43. </div>
  44. <div class="span9">
  45. <section id="properties">
  46. <h3>Table Properties:</h3>
  47. <table id="table"></table>
  48. </section>
  49. <section id="columns">
  50. <h3>Column Properties:</h3>
  51. <table id="column"></table>
  52. </section>
  53. <section id="events">
  54. <h3>Events:</h3>
  55. <table id="event"></table>
  56. </section>
  57. <section id="methods">
  58. <h3>Methods:</h3>
  59. <table id="method"></table>
  60. </section>
  61. <section id="examples">
  62. <h3>Examples:</h3>
  63. <table id="example"></table>
  64. </section>
  65. </div>
  66. </div>
  67. </div>
  68. <a href="https://github.com/wenzhixin/bootstrap-table" class="fork_me"></a>
  69. <script type="text/javascript" src="//wenzhixin.net.cn/js/jquery-1.8.3.min.js"></script>
  70. <script type="text/javascript" src="//wenzhixin.net.cn/js/bootstrap.min.js"></script>
  71. <script type="text/javascript" src="jquery.bootstrap.table.js"></script>
  72. <script type="text/javascript">
  73. $(function() {
  74. $('#table').bootstrapTable({
  75. columns: [
  76. {field: 'name', title: 'Name', align: 'center', width: 60, sortable: true},
  77. {field: 'type', title: 'Type', align: 'center', width: 60},
  78. {field: 'description', title: 'Description', width: 400},
  79. {field: 'default', title: 'Default', align: 'right', width: 180}
  80. ],
  81. data: [
  82. {name: 'height', type: 'Number', description: 'The height of table.', 'default': 'undefined'},
  83. {name: 'sortName', type: 'String', description: 'Defines which column can be sorted.', 'default': 'undefined'},
  84. {name: 'sortOrder', type: 'String', description: 'Defines the column sort order, can only be "asc" or "desc".', 'default': 'asc'},
  85. {name: 'columns', type: 'Array', description: 'The table columns config object, see column properties for more details.', 'default': '[]'},
  86. {name: 'data', type: 'Array', description: 'The data to be loaded.', 'default': '[]'}
  87. ]
  88. });
  89. $('#column').bootstrapTable({
  90. sortName: 'name',
  91. sortOrder: 'asc',
  92. columns: [
  93. {field: 'name', title: 'Name', align: 'center', valign: 'middle', width: 60, sortable: true},
  94. {field: 'type', title: 'Type', align: 'center', valign: 'middle', width: 60},
  95. {field: 'description', title: 'Description', width: 400},
  96. {field: 'default', title: 'Default', align: 'right', valign: 'middle', width: 180}
  97. ],
  98. data: [
  99. {name: 'field', type: 'String', description: 'The column field name.', 'default': 'undefined'},
  100. {name: 'title', type: 'String', description: 'The column title text.', 'default': 'undefined'},
  101. {name: 'align', type: 'String', description: 'Indicate how to align the column data. "left", "right", "center" can be used.', 'default': 'undefined'},
  102. {name: 'valign', type: 'String', description: 'Indicate how to align the cell data. "top", "middle", "bottom" can be used.', 'default': 'undefined'},
  103. {name: 'width', type: 'Number', description: 'The width of column. If not defined, the width will auto expand to fit its contents.', 'default': 'undefined'},
  104. {name: 'sortable', type: 'Boolean', description: 'True to allow the column can be sorted.', 'default': 'false'},
  105. {name: 'order', type: 'String', description: 'The default sort order, can only be "asc" or "desc".', 'default': 'asc'},
  106. {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'},
  107. {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'}
  108. ]
  109. });
  110. $('#event').bootstrapTable({
  111. columns: [
  112. {field: 'name', title: 'Name', align: 'center', valign: 'middle', width: 100, sortable: true},
  113. {field: 'parameter', title: 'Parameter', align: 'center', valign: 'middle', width: 100, sortable: true},
  114. {field: 'description', title: 'Description', width: 400, sortable: true}
  115. ],
  116. data: [
  117. {name: 'onClickRow', parameter: 'row', description: 'Fires when user click a row, the parameters contains: <br />row: the record corresponding to the clicked row'},
  118. {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'}
  119. ],
  120. onClickRow: function(row) {
  121. console.log(row);
  122. },
  123. onSort: function(name, order) {
  124. console.log(name, order);
  125. }
  126. });
  127. $('#method').bootstrapTable({
  128. columns: [
  129. {field: 'name', title: 'Name', align: 'center', valign: 'middle', width: 100},
  130. {field: 'parameter', title: 'Parameter', align: 'center', valign: 'middle', width: 100},
  131. {field: 'description', title: 'Description', width: 400}
  132. ]
  133. }).bootstrapTable('load', [
  134. {name: 'load', parameter: 'data', description: 'Load the data to table.'}
  135. ]).bootstrapTable('append', [
  136. {name: 'append', parameter: 'data', description: 'Append the data to table.'},
  137. {name: 'mergeCells', parameter: 'options', description: 'Merge some cells to one cell, the options contains following properties:'},
  138. {name: 'mergeCells', parameter: 'options', description: 'index: the row index.'},
  139. {name: 'mergeCells', parameter: 'options', description: 'field: the field name.'},
  140. {name: 'mergeCells', parameter: 'options', description: 'rowspan: the rowspan count to be merged.'},
  141. {name: 'mergeCells', parameter: 'options', description: 'colspan: the colspan count to be merged.'}
  142. ]).bootstrapTable('mergeCells', {
  143. index: 2,
  144. field: 'name',
  145. rowspan: 5
  146. }).bootstrapTable('mergeCells', {
  147. index: 2,
  148. field: 'parameter',
  149. rowspan: 5
  150. });
  151. var data = [];
  152. for (var i = 100; i < 1000; i++) {
  153. data.push({code: '' + i, name: 'hello ' + i, price: '$' + i});
  154. }
  155. $('#example').bootstrapTable({
  156. height: 200,
  157. sortName: 'code',
  158. sortOrder: 'asc',
  159. columns: [
  160. {field: 'code', title: 'Code', align: 'left', width: 200, sortable: true},
  161. {field: 'name', title: 'Name', align: 'center', width: 100},
  162. {field: 'price', title: 'Price', align: 'right', valign: 'middle', width: 200, formatter: function(value, row) {
  163. return 'the price is: ' + value;
  164. }}
  165. ],
  166. data: data
  167. });
  168. });
  169. </script>
  170. <script type="text/javascript" src="//wenzhixin.net.cn/js/analytics.js"></script>
  171. </body>
  172. </html>