docs.js 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499
  1. $(function () {
  2. 'use strict';
  3. function initTables() {
  4. var cardView = false;
  5. if ($(window).width() < 640) {
  6. cardView = true;
  7. }
  8. $('#table, #column, #event, #method, #localization').bootstrapTable('destroy');
  9. $('#table').bootstrapTable({
  10. cardView: cardView,
  11. columns: [
  12. {field: 'name', title: 'Name', align: 'center', sortable: true},
  13. {field: 'attribute', title: 'Attribute', align: 'center'},
  14. {field: 'type', title: 'Type', align: 'center'},
  15. {field: 'description', title: 'Description'},
  16. {field: 'default', title: 'Default'}
  17. ],
  18. data: [
  19. {
  20. name: 'classes',
  21. attribute: 'data-classes',
  22. type: 'String',
  23. description: 'The class name of table.',
  24. 'default': 'table table-hover'
  25. },
  26. {
  27. name: 'height',
  28. attribute: 'data-height',
  29. type: 'Number',
  30. description: 'The height of table.',
  31. 'default': 'undefined'
  32. },
  33. {
  34. name: 'undefinedText',
  35. attribute: 'data-undefined-text',
  36. type: 'String',
  37. description: 'Defines the default undefined text.',
  38. 'default': '-'
  39. },
  40. {
  41. name: 'striped',
  42. attribute: 'data-striped',
  43. type: 'Boolean',
  44. description: 'True to stripe the rows.',
  45. 'default': 'false'
  46. },
  47. {
  48. name: 'sortName',
  49. attribute: 'data-sort-name',
  50. type: 'String',
  51. description: 'Defines which column can be sorted.',
  52. 'default': 'undefined'
  53. },
  54. {
  55. name: 'sortOrder',
  56. attribute: 'data-sort-order',
  57. type: 'String',
  58. description: 'Defines the column sort order, can only be "asc" or "desc".',
  59. 'default': 'asc'
  60. },
  61. {
  62. name: 'columns',
  63. attribute: '-',
  64. type: 'Array',
  65. description: 'The table columns config object, see column properties for more details.',
  66. 'default': '[]'
  67. },
  68. {
  69. name: 'data',
  70. attribute: '-',
  71. type: 'Array',
  72. description: 'The data to be loaded.',
  73. 'default': '[]'
  74. },
  75. {
  76. name: 'method',
  77. attribute: 'data-method',
  78. type: 'String',
  79. description: 'The method type to request remote data.',
  80. 'default': 'get'
  81. },
  82. {
  83. name: 'url',
  84. attribute: 'data-url',
  85. type: 'String',
  86. description: 'A URL to request data from remote site.',
  87. 'default': 'undefined'
  88. },
  89. {
  90. name: 'contentType',
  91. attribute: 'data-content-type',
  92. type: 'String',
  93. description: 'The contentType of request remote data.',
  94. 'default': 'application/json'
  95. },
  96. {
  97. name: 'queryParams',
  98. attribute: 'data-query-params',
  99. type: 'Function',
  100. description: 'When request remote data, sending additional parameters by format the queryParams, the parameters object contains: <br>pageSize, pageNumber, searchText, sortName, sortOrder.',
  101. 'default': 'function(params) {<br>return {};<br>}'
  102. },
  103. {
  104. name: 'responseHandler',
  105. attribute: 'data-response-handler',
  106. type: 'Function',
  107. description: 'Before load remote data, handler the response data format, the parameters object contains: <br>res: the response data.',
  108. 'default': 'function(res) {<br>return res;<br>}'
  109. },
  110. {
  111. name: 'pagination',
  112. attribute: 'data-pagination',
  113. type: 'Boolean',
  114. description: 'True to show a pagination toolbar on datagrid bottom.',
  115. 'default': 'false'
  116. },
  117. {
  118. name: 'sidePagination',
  119. attribute: 'data-side-pagination',
  120. type: 'String',
  121. description: 'Defines the side pagination of table, can only be "client" or "server".',
  122. 'default': 'client'
  123. },
  124. {
  125. name: 'totalRows',
  126. attribute: 'data-total-rows',
  127. type: 'Number',
  128. description: 'Defines the total rows of table, you need to set this option when the sidePagination option is set to "server".',
  129. 'default': 0
  130. },
  131. {
  132. name: 'pageNumber',
  133. attribute: 'data-page-number',
  134. type: 'Number',
  135. description: 'When set pagination property, initialize the page number.',
  136. 'default': 1
  137. },
  138. {
  139. name: 'pageSize',
  140. attribute: 'data-page-size',
  141. type: 'Number',
  142. description: 'When set pagination property, initialize the page size.',
  143. 'default': 10
  144. },
  145. {
  146. name: 'pageList',
  147. attribute: 'data-page-list',
  148. type: 'Array',
  149. description: 'When set pagination property, initialize the page size selecting list.',
  150. 'default': '[10, 25, 50, 100]'
  151. },
  152. {
  153. name: 'search',
  154. attribute: 'data-search',
  155. type: 'Boolean',
  156. description: 'Enable the search input.',
  157. 'default': 'false'
  158. },
  159. {
  160. name: 'selectItemName',
  161. attribute: 'data-select-item-name',
  162. type: 'String',
  163. description: 'The name of radio or checkbox input.',
  164. 'default': 'btSelectItem'
  165. },
  166. {
  167. name: 'showHeader',
  168. attribute: 'data-show-header',
  169. type: 'Boolean',
  170. description: 'False to hide the table header.',
  171. 'default': 'true'
  172. },
  173. {
  174. name: 'showColumns',
  175. attribute: 'data-show-columns',
  176. type: 'Boolean',
  177. description: 'True to show the columns drop down list.',
  178. 'default': 'false'
  179. },
  180. {
  181. name: 'minimunCountColumns',
  182. attribute: 'data-minimun-count-columns',
  183. type: 'Number',
  184. description: 'The minimun count columns to hide of the columns drop down list.',
  185. 'default': '1'
  186. },
  187. {
  188. name: 'idField',
  189. attribute: 'data-id-field',
  190. type: 'String',
  191. description: 'Indicate which field is an identity field.',
  192. 'default': 'undefined'
  193. },
  194. {
  195. name: 'cardView',
  196. attribute: 'data-card-view',
  197. type: 'Boolean',
  198. description: 'True to show card view table, for example mobile view.',
  199. 'default': 'false'
  200. },
  201. {
  202. name: 'clickToSelect',
  203. attribute: 'data-click-to-select',
  204. type: 'Boolean',
  205. description: 'True to select checkbox or radiobox when click rows.',
  206. 'default': 'false'
  207. },
  208. {
  209. name: 'singleSelect',
  210. attribute: 'data-single-select',
  211. type: 'Boolean',
  212. description: 'True to allow checkbox selecting only one row.',
  213. 'default': 'false'
  214. },
  215. {
  216. name: 'toolbar',
  217. attribute: 'data-toolbar',
  218. type: 'String',
  219. description: 'A jQuery selector that indicate the toolbar, for example: <br>#toolbar, .toolbar.',
  220. 'default': 'undefined'
  221. },
  222. {
  223. name: 'rowStyle',
  224. attribute: 'data-row-style',
  225. type: 'Function',
  226. description: 'The row formatter function, take two parameters: <br>row: the row record data.<br>index: the row index.<br>Support classes or css, code example:<br><pre>return {<br> classes: "red", <br> css: {background: "red", color: "white"}<br>}</pre>',
  227. 'default': '{}'
  228. }
  229. ]
  230. });
  231. $('#column').bootstrapTable({
  232. cardView: cardView,
  233. columns: [
  234. {field: 'name', title: 'Name', align: 'center', valign: 'middle', width: 60, sortable: true},
  235. {field: 'attribute', title: 'Attribute', align: 'center', valign: 'middle'},
  236. {field: 'type', title: 'Type', align: 'center', valign: 'middle', width: 60},
  237. {field: 'description', title: 'Description', valign: 'middle', width: 400},
  238. {field: 'default', title: 'Default', align: 'right', valign: 'middle', width: 180}
  239. ],
  240. data: [
  241. {
  242. name: 'radio',
  243. attribute: 'data-radio',
  244. type: 'Boolean',
  245. description: 'True to show a radio. The radio column has fixed width.',
  246. 'default': 'false'
  247. },
  248. {
  249. name: 'checkbox',
  250. attribute: 'data-checkbox',
  251. type: 'Boolean',
  252. description: 'True to show a checkbox. The checkbox column has fixed width.',
  253. 'default': 'false'
  254. },
  255. {
  256. name: 'field',
  257. attribute: 'data-field',
  258. type: 'String',
  259. description: 'The column field name.',
  260. 'default': 'undefined'
  261. },
  262. {
  263. name: 'title',
  264. attribute: 'data-title',
  265. type: 'String',
  266. description: 'The column title text.',
  267. 'default': 'undefined'
  268. },
  269. {
  270. name: 'class',
  271. attribute: 'class / data-class',
  272. type: 'String',
  273. description: 'The column class name.',
  274. 'default': 'undefined'
  275. },
  276. {
  277. name: 'align',
  278. attribute: 'data-align',
  279. type: 'String',
  280. description: 'Indicate how to align the column data. "left", "right", "center" can be used.',
  281. 'default': 'undefined'},
  282. {
  283. name: 'valign',
  284. attribute: 'data-valign',
  285. type: 'String',
  286. description: 'Indicate how to align the cell data. "top", "middle", "bottom" can be used.',
  287. 'default': 'undefined'
  288. },
  289. {
  290. name: 'width',
  291. attribute: 'data-width',
  292. type: 'Number',
  293. description: 'The width of column. If not defined, the width will auto expand to fit its contents.',
  294. 'default': 'undefined'},
  295. {
  296. name: 'sortable',
  297. attribute: 'data-sortable',
  298. type: 'Boolean',
  299. description: 'True to allow the column can be sorted.',
  300. 'default': 'false'
  301. },
  302. {
  303. name: 'order',
  304. attribute: 'data-order',
  305. type: 'String',
  306. description: 'The default sort order, can only be "asc" or "desc".',
  307. 'default': 'asc'
  308. },
  309. {
  310. name: 'visible',
  311. attribute: 'data-visible',
  312. type: 'Boolean',
  313. description: 'True to visible the columns item.',
  314. 'default': 'true'
  315. },
  316. {
  317. name: 'switchable',
  318. attribute: 'data-switchable',
  319. type: 'Boolean',
  320. description: 'False to disable the switchable of columns item.',
  321. 'default': 'true'
  322. },
  323. {
  324. name: 'formatter',
  325. attribute: 'data-formatter',
  326. type: 'Function',
  327. description: 'The cell formatter function, take two parameters: <br />value: the field value. <br />row: the row record data.<br />index: the row index.',
  328. 'default': 'undefined'
  329. },
  330. {
  331. name: 'sorter',
  332. attribute: 'data-sorter',
  333. type: 'Function',
  334. 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.',
  335. 'default': 'undefined'
  336. }
  337. ]
  338. });
  339. $('#event').bootstrapTable({
  340. cardView: cardView,
  341. columns: [
  342. {field: 'name', title: 'Option Event', align: 'center', valign: 'middle', width: 100, sortable: true},
  343. {field: 'event', title: 'jQuery Event', align: 'center', valign: 'middle', width: 100, sortable: true},
  344. {field: 'parameter', title: 'Parameter', align: 'center', valign: 'middle', width: 100, sortable: true},
  345. {field: 'description', title: 'Description', width: 400, sortable: true}
  346. ],
  347. data: [
  348. {
  349. name: 'onAll',
  350. event: 'all.bs.table',
  351. parameter: 'name, args',
  352. description: 'Fires when all events trigger, the parameters contains: <br />name: the event name, <br>args: the event data.'
  353. },
  354. {
  355. name: 'onClickRow',
  356. event: 'click-row.bs.table',
  357. parameter: 'row, $element',
  358. description: 'Fires when user click a row, the parameters contains: <br />row: the record corresponding to the clicked row, <br>$element: the tr element.'
  359. },
  360. {
  361. name: 'onDblClickRow',
  362. event: 'dbl-click-row.bs.table',
  363. parameter: 'row, $element',
  364. description: 'Fires when user click a row, the parameters contains: <br />row: the record corresponding to the clicked row, <br>$element: the tr element.'
  365. },
  366. {
  367. name: 'onSort',
  368. event: 'sort.bs.table',
  369. parameter: 'name, order',
  370. description: 'Fires when user sort a column, the parameters contains: <br />name: the sort column field name<br />order: the sort column order.'
  371. },
  372. {
  373. name: 'onCheck',
  374. event: 'check.bs.table',
  375. parameter: 'row',
  376. description: 'Fires when user check a row, the parameters contains: <br />row: the record corresponding to the clicked row.'
  377. },
  378. {
  379. name: 'onUncheck',
  380. event: 'uncheck.bs.table',
  381. parameter: 'row',
  382. description: 'Fires when user uncheck a row, the parameters contains: <br />row: the record corresponding to the clicked row.'
  383. },
  384. {
  385. name: 'onCheckAll',
  386. event: 'check-all.bs.table',
  387. parameter: 'none',
  388. description: 'Fires when user check all rows.'
  389. },
  390. {
  391. name: 'onUncheckAll',
  392. event: 'uncheck-all.bs.table',
  393. parameter: 'none',
  394. description: 'Fires when user uncheck all rows.'
  395. },
  396. {
  397. name: 'onLoadSuccess',
  398. event: 'load-success.bs.table',
  399. parameter: 'data',
  400. description: 'Fires when remote data is loaded successfully.'
  401. },
  402. {
  403. name: 'onLoadError',
  404. event: 'load-error.bs.table',
  405. parameter: 'status',
  406. description: 'Fires when some errors occur to load remote data.'
  407. }
  408. ],
  409. onClickRow: function (row) {
  410. console.log('onClickRow', row);
  411. },
  412. onSort: function (name, order) {
  413. console.log('onSort', name, order);
  414. },
  415. onCheck: function(row) {
  416. console.log('onCheck', row);
  417. },
  418. onUncheck: function(row) {
  419. console.log('onUncheck', row);
  420. },
  421. onCheckAll: function() {
  422. console.log('onCheckAll');
  423. },
  424. onUncheckAll: function() {
  425. console.log('onUncheckAll');
  426. }
  427. });
  428. $('#method').bootstrapTable({
  429. cardView: cardView,
  430. columns: [
  431. {field: 'name', title: 'Name', align: 'center', valign: 'middle', width: 100},
  432. {field: 'parameter', title: 'Parameter', align: 'center', valign: 'middle', width: 100},
  433. {field: 'description', title: 'Description', width: 400}
  434. ]
  435. }).bootstrapTable('load', [
  436. {name: 'getSelections', parameter: 'none', description: 'Return all selected rows, when no record selected, am empty array will return.'},
  437. {name: 'load', parameter: 'data', description: 'Load the data to table.'}
  438. ]).bootstrapTable('append', [
  439. {name: 'append', parameter: 'data', description: 'Append the data to table.'},
  440. {name: 'mergeCells', parameter: 'options', description: 'Merge some cells to one cell, the options contains following properties:'},
  441. {name: 'mergeCells', parameter: 'options', description: 'index: the row index.'},
  442. {name: 'mergeCells', parameter: 'options', description: 'field: the field name.'},
  443. {name: 'mergeCells', parameter: 'options', description: 'rowspan: the rowspan count to be merged.'},
  444. {name: 'mergeCells', parameter: 'options', description: 'colspan: the colspan count to be merged.'},
  445. {name: 'refresh', parameter: 'none', description: 'Refresh the remote server data.'},
  446. {name: 'showLoading', parameter: 'none', description: 'Show loading status.'},
  447. {name: 'hideLoading', parameter: 'none', description: 'Hide loading status.'},
  448. {name: 'checkAll', parameter: 'none', description: 'Check all current page rows.'},
  449. {name: 'uncheckAll', parameter: 'none', description: 'Uncheck all current page rows.'},
  450. {name: 'resetView', parameter: 'params', description: 'Reset the bootstrap table view, for example reset the table height.'},
  451. {name: 'destroy', parameter: 'none', description: 'Destroy the bootstrap table.'}
  452. ]).bootstrapTable('mergeCells', {
  453. index: 3,
  454. field: 'name',
  455. rowspan: 5
  456. }).bootstrapTable('mergeCells', {
  457. index: 3,
  458. field: 'parameter',
  459. rowspan: 5
  460. });
  461. $('#localization').bootstrapTable({
  462. cardView: cardView,
  463. columns: [
  464. {field: 'name', title: 'Name', align: 'center', valign: 'middle', width: 100},
  465. {field: 'parameter', title: 'Parameter', align: 'center', valign: 'middle', width: 100},
  466. {field: 'default', title: 'Default', align: 'center', valign: 'middle', width: 200}
  467. ],
  468. data: [{
  469. name: 'formatLoadingMessage',
  470. parameter: '-',
  471. 'default': 'Loading, please wait…'
  472. }, {
  473. name: 'formatRecordsPerPage',
  474. parameter: 'pageNumber',
  475. 'default': '%s records per page'
  476. }, {
  477. name: 'formatShowingRows',
  478. parameter: 'pageFrom, pageTo, totalRows',
  479. 'default': 'Showing %s to %s of %s rows'
  480. }, {
  481. name: 'formatSearch',
  482. parameter: '-',
  483. 'default': 'Search'
  484. }, {
  485. name: 'formatNoMatches',
  486. parameter: '-',
  487. 'default': 'No matching records found'
  488. }]
  489. });
  490. }
  491. $(window).on('resize', initTables);
  492. initTables();
  493. });