docs.js 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266
  1. $(function () {
  2. $('#table').bootstrapTable({
  3. columns: [
  4. {field: 'name', title: 'Name', align: 'center', width: 60, sortable: true},
  5. {field: 'type', title: 'Type', align: 'center', width: 60},
  6. {field: 'description', title: 'Description', width: 400},
  7. {field: 'default', title: 'Default', align: 'right', width: 180}
  8. ],
  9. data: [
  10. {
  11. name: 'classes',
  12. type: 'String',
  13. description: 'The class name of table.',
  14. 'default': 'table table-hover'
  15. },
  16. {
  17. name: 'height',
  18. type: 'Number',
  19. description: 'The height of table.',
  20. 'default': 'undefined'
  21. },
  22. {
  23. name: 'undefinedText',
  24. type: 'String',
  25. description: 'Defines the default undefined text.',
  26. 'default': '-'
  27. },
  28. {
  29. name: 'striped',
  30. type: 'Boolean',
  31. description: 'True to stripe the rows.',
  32. 'default': 'false'
  33. },
  34. {
  35. name: 'sortName',
  36. type: 'String',
  37. description: 'Defines which column can be sorted.',
  38. 'default': 'undefined'
  39. },
  40. {
  41. name: 'sortOrder',
  42. type: 'String',
  43. description: 'Defines the column sort order, can only be "asc" or "desc".',
  44. 'default': 'asc'
  45. },
  46. {
  47. name: 'columns',
  48. type: 'Array',
  49. description: 'The table columns config object, see column properties for more details.',
  50. 'default': '[]'
  51. },
  52. {
  53. name: 'data',
  54. type: 'Array',
  55. description: 'The data to be loaded.',
  56. 'default': '[]'
  57. },
  58. {
  59. name: 'method',
  60. type: 'String',
  61. description: 'The method type to request remote data.',
  62. 'default': 'get'
  63. },
  64. {
  65. name: 'url',
  66. type: 'String',
  67. description: 'A URL to request data from remote site.',
  68. 'default': 'undefined'
  69. },
  70. {
  71. name: 'queryParams',
  72. type: 'Object',
  73. description: 'When request remote data, sending additional parameters also.',
  74. 'default': '{}'
  75. },
  76. {
  77. name: 'pagination',
  78. type: 'Boolean',
  79. description: 'True to show a pagination toolbar on datagrid bottom.',
  80. 'default': 'false'
  81. },
  82. {
  83. name: 'sidePagination',
  84. type: 'String',
  85. description: 'Defines the side pagination of table, can only be "client" or "server".',
  86. 'default': 'client'
  87. },
  88. {
  89. name: 'totalRows',
  90. type: 'Number',
  91. description: 'Defines the total rows of table, you need to set this option when the sidePagination option is set to "server".',
  92. 'default': 0
  93. },
  94. {
  95. name: 'pageNumber',
  96. type: 'Number',
  97. description: 'When set pagination property, initialize the page number.',
  98. 'default': 1
  99. },
  100. {
  101. name: 'pageSize',
  102. type: 'Number',
  103. description: 'When set pagination property, initialize the page size.',
  104. 'default': 10
  105. },
  106. {
  107. name: 'pageList',
  108. type: 'Array',
  109. description: 'When set pagination property, initialize the page size selecting list.',
  110. 'default': '[10, 20, 30, 40, 50]'
  111. }
  112. ]
  113. });
  114. $('#column').bootstrapTable({
  115. columns: [
  116. {field: 'name', title: 'Name', align: 'center', valign: 'middle', width: 60, sortable: true},
  117. {field: 'type', title: 'Type', align: 'center', valign: 'middle', width: 60},
  118. {field: 'description', title: 'Description', width: 400},
  119. {field: 'default', title: 'Default', align: 'right', valign: 'middle', width: 180}
  120. ],
  121. data: [
  122. {
  123. name: 'radio',
  124. type: 'Boolean',
  125. description: 'True to show a radio. The radio column has fixed width.',
  126. 'default': 'false'
  127. },
  128. {
  129. name: 'checkbox',
  130. type: 'Boolean',
  131. description: 'True to show a checkbox. The checkbox column has fixed width.',
  132. 'default': 'false'
  133. },
  134. {
  135. name: 'field',
  136. type: 'String',
  137. description: 'The column field name.',
  138. 'default': 'undefined'
  139. },
  140. {
  141. name: 'title',
  142. type: 'String',
  143. description: 'The column title text.',
  144. 'default': 'undefined'
  145. },
  146. {
  147. name: 'align',
  148. type: 'String',
  149. description: 'Indicate how to align the column data. "left", "right", "center" can be used.',
  150. 'default': 'undefined'},
  151. {
  152. name: 'valign',
  153. type: 'String',
  154. description: 'Indicate how to align the cell data. "top", "middle", "bottom" can be used.',
  155. 'default': 'undefined'
  156. },
  157. {
  158. name: 'width',
  159. type: 'Number',
  160. description: 'The width of column. If not defined, the width will auto expand to fit its contents.',
  161. 'default': 'undefined'},
  162. {
  163. name: 'sortable',
  164. type: 'Boolean',
  165. description: 'True to allow the column can be sorted.',
  166. 'default': 'false'
  167. },
  168. {
  169. name: 'order',
  170. type: 'String',
  171. description: 'The default sort order, can only be "asc" or "desc".',
  172. 'default': 'asc'
  173. },
  174. {
  175. name: 'formatter',
  176. type: 'Function',
  177. description: 'The cell formatter function, take two parameters: <br />value: the field value. <br />row: the row record data.',
  178. 'default': 'undefined'
  179. },
  180. {
  181. name: 'sorter',
  182. type: 'Function',
  183. 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.',
  184. 'default': 'undefined'
  185. }
  186. ]
  187. });
  188. $('#event').bootstrapTable({
  189. columns: [
  190. {field: 'name', title: 'Name', align: 'center', valign: 'middle', width: 100, sortable: true},
  191. {field: 'parameter', title: 'Parameter', align: 'center', valign: 'middle', width: 100, sortable: true},
  192. {field: 'description', title: 'Description', width: 400, sortable: true}
  193. ],
  194. data: [
  195. {name: 'onClickRow', parameter: 'row', description: 'Fires when user click a row, the parameters contains: <br />row: the record corresponding to the clicked row'},
  196. {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'}
  197. ],
  198. onClickRow: function (row) {
  199. console.log(row);
  200. },
  201. onSort: function (name, order) {
  202. console.log(name, order);
  203. }
  204. });
  205. $('#method').bootstrapTable({
  206. columns: [
  207. {field: 'name', title: 'Name', align: 'center', valign: 'middle', width: 100},
  208. {field: 'parameter', title: 'Parameter', align: 'center', valign: 'middle', width: 100},
  209. {field: 'description', title: 'Description', width: 400}
  210. ]
  211. }).bootstrapTable('load', [
  212. {name: 'getSelections', parameter: 'none', description: 'Return all selected rows, when no record selected, am empty array will return.'},
  213. {name: 'load', parameter: 'data', description: 'Load the data to table.'}
  214. ]).bootstrapTable('append', [
  215. {name: 'append', parameter: 'data', description: 'Append the data to table.'},
  216. {name: 'mergeCells', parameter: 'options', description: 'Merge some cells to one cell, the options contains following properties:'},
  217. {name: 'mergeCells', parameter: 'options', description: 'index: the row index.'},
  218. {name: 'mergeCells', parameter: 'options', description: 'field: the field name.'},
  219. {name: 'mergeCells', parameter: 'options', description: 'rowspan: the rowspan count to be merged.'},
  220. {name: 'mergeCells', parameter: 'options', description: 'colspan: the colspan count to be merged.'},
  221. {name: 'checkAll', parameter: 'none', description: 'Check all current page rows.'},
  222. {name: 'uncheckAll', parameter: 'none', description: 'Uncheck all current page rows.'}
  223. ]).bootstrapTable('mergeCells', {
  224. index: 3,
  225. field: 'name',
  226. rowspan: 5
  227. }).bootstrapTable('mergeCells', {
  228. index: 3,
  229. field: 'parameter',
  230. rowspan: 5
  231. });
  232. var $window = $(window);
  233. var $body = $(document.body);
  234. var navHeight = $('.navbar').outerHeight(true) + 10;
  235. $body.scrollspy({
  236. target: '.bs-sidebar',
  237. offset: navHeight
  238. });
  239. $window.on('load', function () {
  240. $body.scrollspy('refresh')
  241. });
  242. // affix
  243. setTimeout(function () {
  244. var $sideBar = $('.bs-sidebar');
  245. $sideBar.affix({
  246. offset: {
  247. top: function () {
  248. var offsetTop = $sideBar.offset().top;
  249. var sideBarMargin = parseInt($sideBar.children(0).css('margin-top'), 10);
  250. var navOuterHeight = $('.bs-docs-nav').height();
  251. return (this.top = offsetTop - navOuterHeight - sideBarMargin);
  252. },
  253. bottom: function () {
  254. return (this.bottom = $('.bs-footer').outerHeight(true));
  255. }
  256. }
  257. });
  258. }, 100)
  259. });