docs.js 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384
  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, 25, 50, 100]'
  111. },
  112. {
  113. name: 'search',
  114. type: 'Boolean',
  115. description: 'Enable the search input.',
  116. 'default': 'false'
  117. },
  118. {
  119. name: 'selectItemName',
  120. type: 'String',
  121. description: 'The name of radio or checkbox input.',
  122. 'default': 'btSelectItem'
  123. },
  124. {
  125. name: 'showHeader',
  126. type: 'Boolean',
  127. description: 'False to hide the table header.',
  128. 'default': 'true'
  129. },
  130. {
  131. name: 'showColumns',
  132. type: 'Boolean',
  133. description: 'True to show the columns drop down list.',
  134. 'default': 'false'
  135. },
  136. {
  137. name: 'idField',
  138. type: 'String',
  139. description: 'Indicate which field is an identity field.',
  140. 'default': 'undefined'
  141. },
  142. {
  143. name: 'cardView',
  144. type: 'Boolean',
  145. description: 'True to show card view table, for example mobile view.',
  146. 'default': 'false'
  147. },
  148. {
  149. name: 'clickToSelect',
  150. type: 'Boolean',
  151. description: 'True to select checkbox or radiobox when click rows.',
  152. 'default': 'false'
  153. }
  154. ]
  155. });
  156. $('#column').bootstrapTable({
  157. columns: [
  158. {field: 'name', title: 'Name', align: 'center', valign: 'middle', width: 60, sortable: true},
  159. {field: 'type', title: 'Type', align: 'center', valign: 'middle', width: 60},
  160. {field: 'description', title: 'Description', width: 400},
  161. {field: 'default', title: 'Default', align: 'right', valign: 'middle', width: 180}
  162. ],
  163. data: [
  164. {
  165. name: 'radio',
  166. type: 'Boolean',
  167. description: 'True to show a radio. The radio column has fixed width.',
  168. 'default': 'false'
  169. },
  170. {
  171. name: 'checkbox',
  172. type: 'Boolean',
  173. description: 'True to show a checkbox. The checkbox column has fixed width.',
  174. 'default': 'false'
  175. },
  176. {
  177. name: 'field',
  178. type: 'String',
  179. description: 'The column field name.',
  180. 'default': 'undefined'
  181. },
  182. {
  183. name: 'title',
  184. type: 'String',
  185. description: 'The column title text.',
  186. 'default': 'undefined'
  187. },
  188. {
  189. name: 'align',
  190. type: 'String',
  191. description: 'Indicate how to align the column data. "left", "right", "center" can be used.',
  192. 'default': 'undefined'},
  193. {
  194. name: 'valign',
  195. type: 'String',
  196. description: 'Indicate how to align the cell data. "top", "middle", "bottom" can be used.',
  197. 'default': 'undefined'
  198. },
  199. {
  200. name: 'width',
  201. type: 'Number',
  202. description: 'The width of column. If not defined, the width will auto expand to fit its contents.',
  203. 'default': 'undefined'},
  204. {
  205. name: 'sortable',
  206. type: 'Boolean',
  207. description: 'True to allow the column can be sorted.',
  208. 'default': 'false'
  209. },
  210. {
  211. name: 'order',
  212. type: 'String',
  213. description: 'The default sort order, can only be "asc" or "desc".',
  214. 'default': 'asc'
  215. },
  216. {
  217. name: 'visible',
  218. type: 'Boolean',
  219. description: 'True to visible the columns item.',
  220. 'default': 'true'
  221. },
  222. {
  223. name: 'formatter',
  224. type: 'Function',
  225. description: 'The cell formatter function, take two parameters: <br />value: the field value. <br />row: the row record data.',
  226. 'default': 'undefined'
  227. },
  228. {
  229. name: 'sorter',
  230. type: 'Function',
  231. 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.',
  232. 'default': 'undefined'
  233. }
  234. ]
  235. });
  236. $('#event').bootstrapTable({
  237. columns: [
  238. {field: 'name', title: 'Name', align: 'center', valign: 'middle', width: 100, sortable: true},
  239. {field: 'parameter', title: 'Parameter', align: 'center', valign: 'middle', width: 100, sortable: true},
  240. {field: 'description', title: 'Description', width: 400, sortable: true}
  241. ],
  242. data: [
  243. {
  244. name: 'onClickRow',
  245. parameter: 'row',
  246. description: 'Fires when user click a row, the parameters contains: <br />row: the record corresponding to the clicked row.'},
  247. {
  248. name: 'onSort',
  249. parameter: 'name, order',
  250. description: 'Fires when user sort a column, the parameters contains: <br />name: the sort column field name<br />order: the sort column order.'
  251. },
  252. {
  253. name: 'onCheck',
  254. parameter: 'row',
  255. description: 'Fires when user check a row, the parameters contains: <br />row: the record corresponding to the clicked row.'
  256. },
  257. {
  258. name: 'onUncheck',
  259. parameter: 'row',
  260. description: 'Fires when user uncheck a row, the parameters contains: <br />row: the record corresponding to the clicked row.'
  261. },
  262. {
  263. name: 'onCheckAll',
  264. parameter: 'none',
  265. description: 'Fires when user check all rows.'
  266. },
  267. {
  268. name: 'onUncheckAll',
  269. parameter: 'none',
  270. description: 'Fires when user uncheck all rows.'
  271. }
  272. ],
  273. onClickRow: function (row) {
  274. console.log('onClickRow', row);
  275. },
  276. onSort: function (name, order) {
  277. console.log('onSort', name, order);
  278. },
  279. onCheck: function(row) {
  280. console.log('onCheck', row);
  281. },
  282. onUncheck: function(row) {
  283. console.log('onUncheck', row);
  284. },
  285. onCheckAll: function() {
  286. console.log('onCheckAll');
  287. },
  288. onUncheckAll: function() {
  289. console.log('onUncheckAll');
  290. }
  291. });
  292. $('#method').bootstrapTable({
  293. columns: [
  294. {field: 'name', title: 'Name', align: 'center', valign: 'middle', width: 100},
  295. {field: 'parameter', title: 'Parameter', align: 'center', valign: 'middle', width: 100},
  296. {field: 'description', title: 'Description', width: 400}
  297. ]
  298. }).bootstrapTable('load', [
  299. {name: 'getSelections', parameter: 'none', description: 'Return all selected rows, when no record selected, am empty array will return.'},
  300. {name: 'load', parameter: 'data', description: 'Load the data to table.'}
  301. ]).bootstrapTable('append', [
  302. {name: 'append', parameter: 'data', description: 'Append the data to table.'},
  303. {name: 'mergeCells', parameter: 'options', description: 'Merge some cells to one cell, the options contains following properties:'},
  304. {name: 'mergeCells', parameter: 'options', description: 'index: the row index.'},
  305. {name: 'mergeCells', parameter: 'options', description: 'field: the field name.'},
  306. {name: 'mergeCells', parameter: 'options', description: 'rowspan: the rowspan count to be merged.'},
  307. {name: 'mergeCells', parameter: 'options', description: 'colspan: the colspan count to be merged.'},
  308. {name: 'checkAll', parameter: 'none', description: 'Check all current page rows.'},
  309. {name: 'uncheckAll', parameter: 'none', description: 'Uncheck all current page rows.'},
  310. {name: 'resetView', parameter: 'none', description: 'Reset the bootstrap table view, like display error when init the table with display: none.'},
  311. {name: 'destroy', parameter: 'none', description: 'Destroy the bootstrap table.'}
  312. ]).bootstrapTable('mergeCells', {
  313. index: 3,
  314. field: 'name',
  315. rowspan: 5
  316. }).bootstrapTable('mergeCells', {
  317. index: 3,
  318. field: 'parameter',
  319. rowspan: 5
  320. });
  321. $('#localization').bootstrapTable({
  322. columns: [
  323. {field: 'name', title: 'Name', align: 'center', valign: 'middle', width: 100},
  324. {field: 'parameter', title: 'Parameter', align: 'center', valign: 'middle', width: 100},
  325. {field: 'default', title: 'Default', align: 'center', valign: 'middle', width: 200}
  326. ],
  327. data: [{
  328. name: 'formatLoadingMessage',
  329. parameter: '-',
  330. 'default': 'Loading, please wait…'
  331. }, {
  332. name: 'formatRecordsPerPage',
  333. parameter: 'pageNumber',
  334. 'default': '%s records per page'
  335. }, {
  336. name: 'formatShowingRows',
  337. parameter: 'pageFrom, pageTo, totalRows',
  338. 'default': 'Showing %s to %s of %s rows'
  339. }, {
  340. name: 'formatSearch',
  341. parameter: '-',
  342. 'default': 'Search'
  343. }, {
  344. name: 'formatNoMatches',
  345. parameter: '-',
  346. 'default': 'No matching records found'
  347. }]
  348. });
  349. var $window = $(window);
  350. var $body = $(document.body);
  351. var navHeight = $('.navbar').outerHeight(true) + 10;
  352. $body.scrollspy({
  353. target: '.bs-sidebar',
  354. offset: navHeight
  355. });
  356. $window.on('load', function () {
  357. $body.scrollspy('refresh')
  358. });
  359. // affix
  360. setTimeout(function () {
  361. var $sideBar = $('.bs-sidebar');
  362. $sideBar.affix({
  363. offset: {
  364. top: function () {
  365. var offsetTop = $sideBar.offset().top;
  366. var sideBarMargin = parseInt($sideBar.children(0).css('margin-top'), 10);
  367. var navOuterHeight = $('.bs-docs-nav').height();
  368. return (this.top = offsetTop - navOuterHeight - sideBarMargin);
  369. },
  370. bottom: function () {
  371. return (this.bottom = $('.bs-footer').outerHeight(true));
  372. }
  373. }
  374. });
  375. }, 100)
  376. });