docs.js 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399
  1. $(function () {
  2. 'use strict';
  3. $('#table').bootstrapTable({
  4. columns: [
  5. {field: 'name', title: 'Name', align: 'center', width: 60, sortable: true},
  6. {field: 'type', title: 'Type', align: 'center', width: 60},
  7. {field: 'description', title: 'Description', width: 400},
  8. {field: 'default', title: 'Default', align: 'right', width: 180}
  9. ],
  10. data: [
  11. {
  12. name: 'classes',
  13. type: 'String',
  14. description: 'The class name of table.',
  15. 'default': 'table table-hover'
  16. },
  17. {
  18. name: 'height',
  19. type: 'Number',
  20. description: 'The height of table.',
  21. 'default': 'undefined'
  22. },
  23. {
  24. name: 'undefinedText',
  25. type: 'String',
  26. description: 'Defines the default undefined text.',
  27. 'default': '-'
  28. },
  29. {
  30. name: 'striped',
  31. type: 'Boolean',
  32. description: 'True to stripe the rows.',
  33. 'default': 'false'
  34. },
  35. {
  36. name: 'sortName',
  37. type: 'String',
  38. description: 'Defines which column can be sorted.',
  39. 'default': 'undefined'
  40. },
  41. {
  42. name: 'sortOrder',
  43. type: 'String',
  44. description: 'Defines the column sort order, can only be "asc" or "desc".',
  45. 'default': 'asc'
  46. },
  47. {
  48. name: 'columns',
  49. type: 'Array',
  50. description: 'The table columns config object, see column properties for more details.',
  51. 'default': '[]'
  52. },
  53. {
  54. name: 'data',
  55. type: 'Array',
  56. description: 'The data to be loaded.',
  57. 'default': '[]'
  58. },
  59. {
  60. name: 'method',
  61. type: 'String',
  62. description: 'The method type to request remote data.',
  63. 'default': 'get'
  64. },
  65. {
  66. name: 'url',
  67. type: 'String',
  68. description: 'A URL to request data from remote site.',
  69. 'default': 'undefined'
  70. },
  71. {
  72. name: 'queryParams',
  73. type: 'Object',
  74. description: 'When request remote data, sending additional parameters also.',
  75. 'default': '{}'
  76. },
  77. {
  78. name: 'pagination',
  79. type: 'Boolean',
  80. description: 'True to show a pagination toolbar on datagrid bottom.',
  81. 'default': 'false'
  82. },
  83. {
  84. name: 'sidePagination',
  85. type: 'String',
  86. description: 'Defines the side pagination of table, can only be "client" or "server".',
  87. 'default': 'client'
  88. },
  89. {
  90. name: 'totalRows',
  91. type: 'Number',
  92. description: 'Defines the total rows of table, you need to set this option when the sidePagination option is set to "server".',
  93. 'default': 0
  94. },
  95. {
  96. name: 'pageNumber',
  97. type: 'Number',
  98. description: 'When set pagination property, initialize the page number.',
  99. 'default': 1
  100. },
  101. {
  102. name: 'pageSize',
  103. type: 'Number',
  104. description: 'When set pagination property, initialize the page size.',
  105. 'default': 10
  106. },
  107. {
  108. name: 'pageList',
  109. type: 'Array',
  110. description: 'When set pagination property, initialize the page size selecting list.',
  111. 'default': '[10, 25, 50, 100]'
  112. },
  113. {
  114. name: 'search',
  115. type: 'Boolean',
  116. description: 'Enable the search input.',
  117. 'default': 'false'
  118. },
  119. {
  120. name: 'selectItemName',
  121. type: 'String',
  122. description: 'The name of radio or checkbox input.',
  123. 'default': 'btSelectItem'
  124. },
  125. {
  126. name: 'showHeader',
  127. type: 'Boolean',
  128. description: 'False to hide the table header.',
  129. 'default': 'true'
  130. },
  131. {
  132. name: 'showColumns',
  133. type: 'Boolean',
  134. description: 'True to show the columns drop down list.',
  135. 'default': 'false'
  136. },
  137. {
  138. name: 'idField',
  139. type: 'String',
  140. description: 'Indicate which field is an identity field.',
  141. 'default': 'undefined'
  142. },
  143. {
  144. name: 'cardView',
  145. type: 'Boolean',
  146. description: 'True to show card view table, for example mobile view.',
  147. 'default': 'false'
  148. },
  149. {
  150. name: 'clickToSelect',
  151. type: 'Boolean',
  152. description: 'True to select checkbox or radiobox when click rows.',
  153. 'default': 'false'
  154. }
  155. ]
  156. });
  157. $('#column').bootstrapTable({
  158. columns: [
  159. {field: 'name', title: 'Name', align: 'center', valign: 'middle', width: 60, sortable: true},
  160. {field: 'type', title: 'Type', align: 'center', valign: 'middle', width: 60},
  161. {field: 'description', title: 'Description', width: 400},
  162. {field: 'default', title: 'Default', align: 'right', valign: 'middle', width: 180}
  163. ],
  164. data: [
  165. {
  166. name: 'radio',
  167. type: 'Boolean',
  168. description: 'True to show a radio. The radio column has fixed width.',
  169. 'default': 'false'
  170. },
  171. {
  172. name: 'checkbox',
  173. type: 'Boolean',
  174. description: 'True to show a checkbox. The checkbox column has fixed width.',
  175. 'default': 'false'
  176. },
  177. {
  178. name: 'field',
  179. type: 'String',
  180. description: 'The column field name.',
  181. 'default': 'undefined'
  182. },
  183. {
  184. name: 'title',
  185. type: 'String',
  186. description: 'The column title text.',
  187. 'default': 'undefined'
  188. },
  189. {
  190. name: 'align',
  191. type: 'String',
  192. description: 'Indicate how to align the column data. "left", "right", "center" can be used.',
  193. 'default': 'undefined'},
  194. {
  195. name: 'valign',
  196. type: 'String',
  197. description: 'Indicate how to align the cell data. "top", "middle", "bottom" can be used.',
  198. 'default': 'undefined'
  199. },
  200. {
  201. name: 'width',
  202. type: 'Number',
  203. description: 'The width of column. If not defined, the width will auto expand to fit its contents.',
  204. 'default': 'undefined'},
  205. {
  206. name: 'sortable',
  207. type: 'Boolean',
  208. description: 'True to allow the column can be sorted.',
  209. 'default': 'false'
  210. },
  211. {
  212. name: 'order',
  213. type: 'String',
  214. description: 'The default sort order, can only be "asc" or "desc".',
  215. 'default': 'asc'
  216. },
  217. {
  218. name: 'visible',
  219. type: 'Boolean',
  220. description: 'True to visible the columns item.',
  221. 'default': 'true'
  222. },
  223. {
  224. name: 'formatter',
  225. type: 'Function',
  226. description: 'The cell formatter function, take two parameters: <br />value: the field value. <br />row: the row record data.<br />index: the row index.',
  227. 'default': 'undefined'
  228. },
  229. {
  230. name: 'sorter',
  231. type: 'Function',
  232. 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.',
  233. 'default': 'undefined'
  234. }
  235. ]
  236. });
  237. $('#event').bootstrapTable({
  238. columns: [
  239. {field: 'name', title: 'Name', align: 'center', valign: 'middle', width: 100, sortable: true},
  240. {field: 'parameter', title: 'Parameter', align: 'center', valign: 'middle', width: 100, sortable: true},
  241. {field: 'description', title: 'Description', width: 400, sortable: true}
  242. ],
  243. data: [
  244. {
  245. name: 'onClickRow',
  246. parameter: 'row',
  247. description: 'Fires when user click a row, the parameters contains: <br />row: the record corresponding to the clicked row.'},
  248. {
  249. name: 'onSort',
  250. parameter: 'name, order',
  251. description: 'Fires when user sort a column, the parameters contains: <br />name: the sort column field name<br />order: the sort column order.'
  252. },
  253. {
  254. name: 'onCheck',
  255. parameter: 'row',
  256. description: 'Fires when user check a row, the parameters contains: <br />row: the record corresponding to the clicked row.'
  257. },
  258. {
  259. name: 'onUncheck',
  260. parameter: 'row',
  261. description: 'Fires when user uncheck a row, the parameters contains: <br />row: the record corresponding to the clicked row.'
  262. },
  263. {
  264. name: 'onCheckAll',
  265. parameter: 'none',
  266. description: 'Fires when user check all rows.'
  267. },
  268. {
  269. name: 'onUncheckAll',
  270. parameter: 'none',
  271. description: 'Fires when user uncheck all rows.'
  272. },
  273. {
  274. name: 'onLoadSuccess',
  275. parameter: 'data',
  276. description: 'Fires when remote data is loaded successfully.'
  277. },
  278. {
  279. name: 'onLoadError',
  280. parameter: 'status',
  281. description: 'Fires when some errors occur to load remote data.'
  282. }
  283. ],
  284. onClickRow: function (row) {
  285. console.log('onClickRow', row);
  286. },
  287. onSort: function (name, order) {
  288. console.log('onSort', name, order);
  289. },
  290. onCheck: function(row) {
  291. console.log('onCheck', row);
  292. },
  293. onUncheck: function(row) {
  294. console.log('onUncheck', row);
  295. },
  296. onCheckAll: function() {
  297. console.log('onCheckAll');
  298. },
  299. onUncheckAll: function() {
  300. console.log('onUncheckAll');
  301. }
  302. });
  303. $('#method').bootstrapTable({
  304. columns: [
  305. {field: 'name', title: 'Name', align: 'center', valign: 'middle', width: 100},
  306. {field: 'parameter', title: 'Parameter', align: 'center', valign: 'middle', width: 100},
  307. {field: 'description', title: 'Description', width: 400}
  308. ]
  309. }).bootstrapTable('load', [
  310. {name: 'getSelections', parameter: 'none', description: 'Return all selected rows, when no record selected, am empty array will return.'},
  311. {name: 'load', parameter: 'data', description: 'Load the data to table.'}
  312. ]).bootstrapTable('append', [
  313. {name: 'append', parameter: 'data', description: 'Append the data to table.'},
  314. {name: 'mergeCells', parameter: 'options', description: 'Merge some cells to one cell, the options contains following properties:'},
  315. {name: 'mergeCells', parameter: 'options', description: 'index: the row index.'},
  316. {name: 'mergeCells', parameter: 'options', description: 'field: the field name.'},
  317. {name: 'mergeCells', parameter: 'options', description: 'rowspan: the rowspan count to be merged.'},
  318. {name: 'mergeCells', parameter: 'options', description: 'colspan: the colspan count to be merged.'},
  319. {name: 'refresh', parameter: 'none', description: 'Refresh the remote server data.'},
  320. {name: 'showLoading', parameter: 'none', description: 'Show loading status.'},
  321. {name: 'hideLoading', parameter: 'none', description: 'Hide loading status.'},
  322. {name: 'checkAll', parameter: 'none', description: 'Check all current page rows.'},
  323. {name: 'uncheckAll', parameter: 'none', description: 'Uncheck all current page rows.'},
  324. {name: 'resetView', parameter: 'none', description: 'Reset the bootstrap table view, like display error when init the table with display: none.'},
  325. {name: 'destroy', parameter: 'none', description: 'Destroy the bootstrap table.'}
  326. ]).bootstrapTable('mergeCells', {
  327. index: 3,
  328. field: 'name',
  329. rowspan: 5
  330. }).bootstrapTable('mergeCells', {
  331. index: 3,
  332. field: 'parameter',
  333. rowspan: 5
  334. });
  335. $('#localization').bootstrapTable({
  336. columns: [
  337. {field: 'name', title: 'Name', align: 'center', valign: 'middle', width: 100},
  338. {field: 'parameter', title: 'Parameter', align: 'center', valign: 'middle', width: 100},
  339. {field: 'default', title: 'Default', align: 'center', valign: 'middle', width: 200}
  340. ],
  341. data: [{
  342. name: 'formatLoadingMessage',
  343. parameter: '-',
  344. 'default': 'Loading, please wait…'
  345. }, {
  346. name: 'formatRecordsPerPage',
  347. parameter: 'pageNumber',
  348. 'default': '%s records per page'
  349. }, {
  350. name: 'formatShowingRows',
  351. parameter: 'pageFrom, pageTo, totalRows',
  352. 'default': 'Showing %s to %s of %s rows'
  353. }, {
  354. name: 'formatSearch',
  355. parameter: '-',
  356. 'default': 'Search'
  357. }, {
  358. name: 'formatNoMatches',
  359. parameter: '-',
  360. 'default': 'No matching records found'
  361. }]
  362. });
  363. var $window = $(window);
  364. var $body = $(document.body);
  365. var navHeight = $('.navbar').outerHeight(true) + 10;
  366. $body.scrollspy({
  367. target: '.bs-sidebar',
  368. offset: navHeight
  369. });
  370. $window.on('load', function () {
  371. $body.scrollspy('refresh')
  372. });
  373. // affix
  374. setTimeout(function () {
  375. var $sideBar = $('.bs-sidebar');
  376. $sideBar.affix({
  377. offset: {
  378. top: function () {
  379. var offsetTop = $sideBar.offset().top;
  380. var sideBarMargin = parseInt($sideBar.children(0).css('margin-top'), 10);
  381. var navOuterHeight = $('.bs-docs-nav').height();
  382. return (this.top = offsetTop - navOuterHeight - sideBarMargin);
  383. },
  384. bottom: function () {
  385. return (this.bottom = $('.bs-footer').outerHeight(true));
  386. }
  387. }
  388. });
  389. }, 100)
  390. });