index.html 8.8 KB

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