Browse Source

Added methods examples

zhixin 6 years ago
parent
commit
6e5d282882
4 changed files with 123 additions and 6 deletions
  1. 1 1
      site/docs/api/column-options.md
  2. 115 3
      site/docs/api/methods.md
  3. 3 1
      src/bootstrap-table.js
  4. 4 1
      tools/check-api.js

+ 1 - 1
site/docs/api/column-options.md

@@ -243,7 +243,7 @@ The column options is defined in `jQuery.fn.bootstrapTable.columnDefaults`.
 
 - **Default:** `true`
 
-- **Example:** [Checkbox Enabled](https://examples.bootstrap-table.com/#column-options/checkbox-enabled.html)
+- **Example:** [Checkbox Enabled](https://examples.bootstrap-table.com/#column-options/checkbox-enabled.html) and [Checkbox Disabled](https://examples.bootstrap-table.com/#column-options/checkbox-disabled.html)
 
 ## clickToSelect
 

+ 115 - 3
site/docs/api/methods.md

@@ -16,6 +16,8 @@ The calling method syntax: `$('#table').bootstrapTable('method', parameter)`.
 
   Return the options object.
 
+- **Example:** [Get Options](https://examples.bootstrap-table.com/#methods/get-options.html)
+
 ## refreshOptions
 
 - **Parameter:** `options`
@@ -24,6 +26,8 @@ The calling method syntax: `$('#table').bootstrapTable('method', parameter)`.
 
   Refresh the table `options`.
 
+- **Example:** [Refresh Options](https://examples.bootstrap-table.com/#methods/refresh-options.html)
+
 ## getData
 
 - **Parameter:** `useCurrentPage`
@@ -32,6 +36,8 @@ The calling method syntax: `$('#table').bootstrapTable('method', parameter)`.
 
   Get the loaded data of table at the moment that this method is called. If you set the `useCurrentPage` to `true` the method will return the data in the current page.
 
+- **Example:** [Get Data](https://examples.bootstrap-table.com/#methods/get-data.html)
+
 ## getSelections
 
 - **Parameter:** `undefined`
@@ -40,6 +46,8 @@ The calling method syntax: `$('#table').bootstrapTable('method', parameter)`.
 
   Return selected rows, when no record selected, an empty array will return.
 
+- **Example:** [Get Selections](https://examples.bootstrap-table.com/#methods/get-selections.html)
+
 ## getAllSelections
 
 - **Parameter:** `undefined`
@@ -48,6 +56,8 @@ The calling method syntax: `$('#table').bootstrapTable('method', parameter)`.
 
   Return all selected rows contain search or filter, when no record selected, an empty array will return.
 
+- **Example:** [Get All Selections](https://examples.bootstrap-table.com/#methods/get-all-selections.html)
+
 ## load
 
 - **Parameter:** `data`
@@ -56,6 +66,8 @@ The calling method syntax: `$('#table').bootstrapTable('method', parameter)`.
 
   Load the `data` to table, the old rows will be removed.
 
+- **Example:** [Load](https://examples.bootstrap-table.com/#methods/load.html)
+
 ## append
 
 - **Parameter:** `data`
@@ -64,6 +76,8 @@ The calling method syntax: `$('#table').bootstrapTable('method', parameter)`.
 
   Append the `data` to table.
 
+- **Example:** [Append](https://examples.bootstrap-table.com/#methods/append.html)
+
 ## prepend
 
 - **Parameter:** `data`
@@ -72,6 +86,8 @@ The calling method syntax: `$('#table').bootstrapTable('method', parameter)`.
 
   Prepend the `data` to table.
 
+- **Example:** [Prepend](https://examples.bootstrap-table.com/#methods/prepend.html)
+
 ## remove
 
 - **Parameter:** `params`
@@ -83,6 +99,8 @@ The calling method syntax: `$('#table').bootstrapTable('method', parameter)`.
   * `field`: the field name of remove rows.
   * `values`: the array of values for rows which should be removed.
 
+- **Example:** [Remove](https://examples.bootstrap-table.com/#methods/remove.html)
+
 ## removeAll
 
 - **Parameter:** `undefined`
@@ -91,6 +109,8 @@ The calling method syntax: `$('#table').bootstrapTable('method', parameter)`.
 
   Remove all data from table.
 
+- **Example:** [Remove All](https://examples.bootstrap-table.com/#methods/remove-all.html)
+
 ## insertRow
 
 - **Parameter:** `params`
@@ -102,6 +122,8 @@ The calling method syntax: `$('#table').bootstrapTable('method', parameter)`.
   * `index`: the row index to insert into.
   * `row`: the row data.
 
+- **Example:** [Insert Row](https://examples.bootstrap-table.com/#methods/insert-row.html)
+
 ## updateRow
 
 - **Parameter:** `params`
@@ -113,6 +135,8 @@ The calling method syntax: `$('#table').bootstrapTable('method', parameter)`.
   * `index`: the row index to be updated.
   * `row`: the new row data.
 
+- **Example:** [Update Row](https://examples.bootstrap-table.com/#methods/update-row.html)
+
 ## getRowByUniqueId
 
 - **Parameter:** `id`
@@ -121,6 +145,8 @@ The calling method syntax: `$('#table').bootstrapTable('method', parameter)`.
 
   Get data from table, the row that contains the `id` passed by parameter.
 
+- **Example:** [Get Row By Unique Id](https://examples.bootstrap-table.com/#methods/get-row-by-unique-id.html)
+
 ## updateByUniqueId
 
 - **Parameter:** `params`
@@ -132,6 +158,8 @@ The calling method syntax: `$('#table').bootstrapTable('method', parameter)`.
   * `id`: a row id where the id should be the uniqueid field assigned to the table.
   * `row`: the new row data.
 
+- **Example:** [Update By Unique Id](https://examples.bootstrap-table.com/#methods/update-by-unique-id.html)
+
 ## removeByUniqueId
 
 - **Parameter:** `id`
@@ -140,6 +168,8 @@ The calling method syntax: `$('#table').bootstrapTable('method', parameter)`.
 
   Remove data from table, the row that contains the `id` passed by parameter.
 
+- **Example:** [Remove By Unique Id](https://examples.bootstrap-table.com/#methods/remove-by-unique-id.html)
+
 ## updateCell
 
 - **Parameter:** `params`
@@ -154,6 +184,8 @@ The calling method syntax: `$('#table').bootstrapTable('method', parameter)`.
 
   To disable table re-initialization you can set `{reinit: false}`.
 
+- **Example:** [Update Cell](https://examples.bootstrap-table.com/#methods/update-cell.html)
+
 ## updateCellByUniqueId
 
 - **Parameter:** `params`
@@ -166,6 +198,8 @@ The calling method syntax: `$('#table').bootstrapTable('method', parameter)`.
   * `field`: field name of the cell to be updated.
   * `value`: new value of the cell.
 
+- **Example:** [Update Cell By Unique Id](https://examples.bootstrap-table.com/#methods/update-cell-by-unique-id.html)
+
 ## showRow
 
 - **Parameter:** `params`
@@ -177,6 +211,8 @@ The calling method syntax: `$('#table').bootstrapTable('method', parameter)`.
   * `index`: the row index.
   * `uniqueId`: the value of the uniqueId for that row.
 
+- **Example:** [Show/Hide Row](https://examples.bootstrap-table.com/#methods/show-hide-row.html)
+
 ## hideRow
 
 - **Parameter:** `params`
@@ -188,6 +224,8 @@ The calling method syntax: `$('#table').bootstrapTable('method', parameter)`.
   * `index`: the row index.
   * `uniqueId`: the value of the uniqueId for that row.
 
+- **Example:** [Show/Hide Row](https://examples.bootstrap-table.com/#methods/show-hide-row.html)
+
 ## getHiddenRows
 
 - **Parameter:** `show`
@@ -196,6 +234,8 @@ The calling method syntax: `$('#table').bootstrapTable('method', parameter)`.
 
   Get all rows hidden and if you pass the `show` parameter `true` the rows will be shown again, otherwise, the method only will return the rows hidden.
 
+- **Example:** [Get Hidden Rows](https://examples.bootstrap-table.com/#methods/get-hidden-rows.html)
+
 ## showColumn
 
 - **Parameter:** `field`
@@ -205,6 +245,8 @@ The calling method syntax: `$('#table').bootstrapTable('method', parameter)`.
   Show the specified `field` column.
   The parameter can be a string or a array of fields.
 
+- **Example:** [Show/Hide Column](https://examples.bootstrap-table.com/#methods/show-hide-column.html)
+
 ## hideColumn
 
 - **Parameter:** `field`
@@ -214,6 +256,8 @@ The calling method syntax: `$('#table').bootstrapTable('method', parameter)`.
   Hide the specified `field` column.
   The parameter can be a string or a array of fields.
 
+- **Example:** [Show/Hide Column](https://examples.bootstrap-table.com/#methods/show-hide-column.html)
+
 ## getVisibleColumns
 
 - **Parameter:** `-`
@@ -222,6 +266,8 @@ The calling method syntax: `$('#table').bootstrapTable('method', parameter)`.
 
   Get visible columns.
 
+- **Example:** [Get Visible/Hidden Columns](https://examples.bootstrap-table.com/#methods/get-visible-hidden-columns.html)
+
 ## getHiddenColumns
 
 - **Parameter:** `undefined`
@@ -230,6 +276,8 @@ The calling method syntax: `$('#table').bootstrapTable('method', parameter)`.
 
   Get hidden columns.
 
+- **Example:** [Get Visible/Hidden Columns](https://examples.bootstrap-table.com/#methods/get-visible-hidden-columns.html)
+
 ## showAllColumns
 
 - **Parameter:** `undefined`
@@ -238,6 +286,8 @@ The calling method syntax: `$('#table').bootstrapTable('method', parameter)`.
 
   Show All the columns.
 
+- **Example:** [Show/Hide All Columns](https://examples.bootstrap-table.com/#methods/show-hide-all-columns.html)
+
 ## hideAllColumns
 
 - **Parameter:** `undefined`
@@ -246,6 +296,8 @@ The calling method syntax: `$('#table').bootstrapTable('method', parameter)`.
 
   Hide All the columns.
 
+- **Example:** [Show/Hide All Columns](https://examples.bootstrap-table.com/#methods/show-hide-all-columns.html)
+
 ## mergeCells
 
 - **Parameter:** `params`
@@ -259,6 +311,8 @@ The calling method syntax: `$('#table').bootstrapTable('method', parameter)`.
   * `rowspan`: the rowspan count to be merged.
   * `colspan`: the colspan count to be merged.
 
+- **Example:** [Merge Cells](https://examples.bootstrap-table.com/#methods/merge-cells.html)
+
 ## checkAll
 
 - **Parameter:** `undefined`
@@ -267,6 +321,8 @@ The calling method syntax: `$('#table').bootstrapTable('method', parameter)`.
 
   Check all current page rows.
 
+- **Example:** [Check/Uncheck All](https://examples.bootstrap-table.com/#methods/check-uncheck-all.html)
+
 ## uncheckAll
 
 - **Parameter:** `undefined`
@@ -275,6 +331,8 @@ The calling method syntax: `$('#table').bootstrapTable('method', parameter)`.
 
   Uncheck all current page rows.
 
+- **Example:** [Check/Uncheck All](https://examples.bootstrap-table.com/#methods/check-uncheck-all.html)
+
 ## checkInvert
 
 - **Parameter:** `undefined`
@@ -283,6 +341,8 @@ The calling method syntax: `$('#table').bootstrapTable('method', parameter)`.
 
   Invert check of current page rows. Triggers `onCheckSome` and `onUncheckSome` events.
 
+- **Example:** [Check Invert](https://examples.bootstrap-table.com/#methods/check-invert.html)
+
 ## check
 
 - **Parameter:** `index`
@@ -291,6 +351,8 @@ The calling method syntax: `$('#table').bootstrapTable('method', parameter)`.
 
   Check a row, the row `index` start with 0.
 
+- **Example:** [Check/Uncheck](https://examples.bootstrap-table.com/#methods/check-uncheck.html)
+
 ## uncheck
 
 - **Parameter:** `index`
@@ -299,6 +361,8 @@ The calling method syntax: `$('#table').bootstrapTable('method', parameter)`.
 
   Uncheck a row, the row `index` start with 0.
 
+- **Example:** [Check/Uncheck](https://examples.bootstrap-table.com/#methods/check-uncheck.html)
+
 ## checkBy
 
 - **Parameter:** `params`
@@ -310,6 +374,8 @@ The calling method syntax: `$('#table').bootstrapTable('method', parameter)`.
   * `field`: name of the field used to find records.
   * `values`: array of values for rows to check.
 
+- **Example:** [Check/Uncheck By](https://examples.bootstrap-table.com/#methods/check-uncheck-by.html)
+
 ## uncheckBy
 
 - **Parameter:** `params`
@@ -321,13 +387,17 @@ The calling method syntax: `$('#table').bootstrapTable('method', parameter)`.
   * `field`: name of the field used to find records.
   * `values`: array of values for rows to uncheck.
 
+- **Example:** [Check/Uncheck By](https://examples.bootstrap-table.com/#methods/check-uncheck-by.html)
+
 ## refresh
 
 - **Parameter:** `params`
 
 - **Detail:**
 
-  Refresh the remote server data, you can set `{silent: true}` to refresh the data silently, and set `{url: newUrl, pageNumber: pageNumber, pageSize: pageSize}` to change the url (optional), page number (optional) and page size (optional). To supply query params specific to this request, set `{query: {foo: 'bar'}}`.
+  Refresh/reload the remote server data, you can set `{silent: true}` to refresh the data silently, and set `{url: newUrl, pageNumber: pageNumber, pageSize: pageSize}` to change the url (optional), page number (optional) and page size (optional). To supply query params specific to this request, set `{query: {foo: 'bar'}}`.
+
+- **Example:** [Refresh](https://examples.bootstrap-table.com/#methods/refresh.html)
 
 ## destroy
 
@@ -337,6 +407,8 @@ The calling method syntax: `$('#table').bootstrapTable('method', parameter)`.
 
   Destroy the Bootstrap Table.
 
+- **Example:** [Destroy](https://examples.bootstrap-table.com/#methods/destroy.html)
+
 ## resetView
 
 - **Parameter:** `params`
@@ -347,6 +419,8 @@ The calling method syntax: `$('#table').bootstrapTable('method', parameter)`.
 
   * `height`: the height of the table.
 
+- **Example:** [Reset View](https://examples.bootstrap-table.com/#methods/reset-view.html)
+
 ## resetWidth
 
 - **Parameter:** `undefined`
@@ -363,6 +437,8 @@ The calling method syntax: `$('#table').bootstrapTable('method', parameter)`.
 
   Show loading status.
 
+- **Example:** [Show/Hide Loading](https://examples.bootstrap-table.com/#methods/show-hide-loading.html)
+
 ## hideLoading
 
 - **Parameter:** `undefined`
@@ -371,6 +447,8 @@ The calling method syntax: `$('#table').bootstrapTable('method', parameter)`.
 
   Hide loading status.
 
+- **Example:** [Show/Hide Loading](https://examples.bootstrap-table.com/#methods/show-hide-loading.html)
+
 ## togglePagination
 
 - **Parameter:** `undefined`
@@ -379,6 +457,8 @@ The calling method syntax: `$('#table').bootstrapTable('method', parameter)`.
 
   Toggle the pagination option.
 
+- **Example:** [Toggle Pagination](https://examples.bootstrap-table.com/#methods/toggle-pagination.html)
+
 ## toggleFullscreen
 
 - **Parameter:** `undefined`
@@ -387,6 +467,8 @@ The calling method syntax: `$('#table').bootstrapTable('method', parameter)`.
 
   Toggle fullscreen.
 
+- **Example:** [Toggle Fullscreen](https://examples.bootstrap-table.com/#methods/toggle-fullscreen.html)
+
 ## toggleView
 
 - **Parameter:** `undefined`
@@ -395,6 +477,8 @@ The calling method syntax: `$('#table').bootstrapTable('method', parameter)`.
 
   Toggle the card/table view.
 
+- **Example:** [Toggle View](https://examples.bootstrap-table.com/#methods/toggle-view.html)
+
 ## resetSearch
 
 - **Parameter:** `text`
@@ -403,6 +487,8 @@ The calling method syntax: `$('#table').bootstrapTable('method', parameter)`.
 
   Set the search `text`.
 
+- **Example:** [Reset Search](https://examples.bootstrap-table.com/#methods/reset-search.html)
+
 ## filterBy
 
 - **Parameter:**
@@ -424,7 +510,7 @@ The calling method syntax: `$('#table').bootstrapTable('method', parameter)`.
   - Set the `filterAlgorithm` (see at parameter) to `or` to use the `or` filter.
   - Pass a function to the `filterAlgorithm` (see at parameter) to use a `custom` filter.
 
-  #####Filter Algorithm
+  **Filter Algorithm**
 
   - And
     - Filter `{age: 10}` to show the data only age is equal to 10.  You can also filter with an array of values, as in: `{age: 10, hairColor: ['blue', 'red', 'green']}` to find data where age is equal to 10 and hairColor is either blue, red, or green.
@@ -437,6 +523,8 @@ The calling method syntax: `$('#table').bootstrapTable('method', parameter)`.
         - Filters
     - Return `true` to keep the row and return `false` to filter the row.
 
+- **Example:** [Filter By](https://examples.bootstrap-table.com/#methods/filter-by.html)
+
 ## scrollTo
 
 - **Parameter:** `value|object`
@@ -449,6 +537,8 @@ The calling method syntax: `$('#table').bootstrapTable('method', parameter)`.
     -  Scroll to the unit (`px` or `rows (index starts by 0)`)
     Default: `{unit: 'px', value: 0}`
 
+- **Example:** [Scroll To](https://examples.bootstrap-table.com/#methods/scorll-to.html)
+
 ## getScrollPosition
 
 - **Parameter:** `undefined`
@@ -457,6 +547,8 @@ The calling method syntax: `$('#table').bootstrapTable('method', parameter)`.
 
   Get the current scroll position, the unit is `'px'`.
 
+- **Example:** [Get Scroll Position](https://examples.bootstrap-table.com/#methods/get-scroll-position.html)
+
 ## selectPage
 
 - **Parameter:** `page`
@@ -465,6 +557,8 @@ The calling method syntax: `$('#table').bootstrapTable('method', parameter)`.
 
   Go to the a specified `page`.
 
+- **Example:** [Select/Prev/Next Page](https://examples.bootstrap-table.com/#methods/select-prev-next-page.html.html)
+
 ## prevPage
 
 - **Parameter:** `undefined`
@@ -473,6 +567,8 @@ The calling method syntax: `$('#table').bootstrapTable('method', parameter)`.
 
   Go to previous page.
 
+- **Example:** [Select/Prev/Next Page](https://examples.bootstrap-table.com/#methods/select-prev-next-page.html.html)
+
 ## nextPage
 
 - **Parameter:** `undefined`
@@ -481,6 +577,8 @@ The calling method syntax: `$('#table').bootstrapTable('method', parameter)`.
 
   Go to next page.
 
+- **Example:** [Select/Prev/Next Page](https://examples.bootstrap-table.com/#methods/select-prev-next-page.html)
+
 ## toggleDetailView
 
 - **Parameter:** `index`
@@ -489,6 +587,8 @@ The calling method syntax: `$('#table').bootstrapTable('method', parameter)`.
 
   Toggle the row that has the `index` passed by parameter if the detail view option is set to `true`.
 
+- **Example:** [Toggle Detail View](https://examples.bootstrap-table.com/#methods/toggle-detail-view.html)
+
 ## expandRow
 
 - **Parameter:** `index`
@@ -497,6 +597,8 @@ The calling method syntax: `$('#table').bootstrapTable('method', parameter)`.
 
   Expand the row that has the `index` passed by parameter if the detail view option is set to `true`.
 
+- **Example:** [Expand/Collapse Row](https://examples.bootstrap-table.com/#methods/expand-collapse-row.html)
+
 ## collapseRow
 
 - **Parameter:** `index`
@@ -505,6 +607,8 @@ The calling method syntax: `$('#table').bootstrapTable('method', parameter)`.
 
   Collapse the row that has the `index` passed by parameter if the detail view option is set to `true`.
 
+- **Example:** [Expand/Collapse Row](https://examples.bootstrap-table.com/#methods/expand-collapse-row.html)
+
 ## expandAllRows
 
 - **Parameter:** `undefined`
@@ -513,6 +617,8 @@ The calling method syntax: `$('#table').bootstrapTable('method', parameter)`.
 
   Expand all rows if the detail view option is set to `true`.
 
+- **Example:** [Expand/Collapse All Rows](https://examples.bootstrap-table.com/#methods/expand-collapse-all-rows.html)
+
 ## collapseAllRows
 
 - **Parameter:** `undefined`
@@ -521,17 +627,21 @@ The calling method syntax: `$('#table').bootstrapTable('method', parameter)`.
 
   Collapse all rows if the detail view option is set to `true`.
 
+- **Example:** [Expand/Collapse All Rows](https://examples.bootstrap-table.com/#methods/expand-collapse-all-rows.html)
+
 ## updateColumnTitle
 
 - **Parameter:** `params`
 
 - **Detail:**
 
-  Refresh the field title of column, the params contain following properties:
+  Update the field title of column, the params contain following properties:
 
   * `field`: the field name.
   * `title`: the field title.
 
+- **Example:** [Update Column Title](https://examples.bootstrap-table.com/#methods/update-column-title.html)
+
 ## updateFormatText
 
 - **Parameter:** `formatName, text`
@@ -539,3 +649,5 @@ The calling method syntax: `$('#table').bootstrapTable('method', parameter)`.
 - **Detail:**
 
   Update the localizations format text.
+
+- **Example:** [Update Format Text](https://examples.bootstrap-table.com/#methods/update-format-text.html)

+ 3 - 1
src/bootstrap-table.js

@@ -2240,7 +2240,9 @@ class BootstrapTable {
 
   _toggleAllColumns (visible) {
     for (const column of this.columns) {
-      column.visible = visible
+      if (column.switchable) {
+        column.visible = visible
+      }
     }
 
     this.initHeader()

+ 4 - 1
tools/check-api.js

@@ -76,7 +76,10 @@ class Methods extends API {
   init () {
     this.file = 'methods.md'
     this.options = Constants.METHODS
-    this.attributes = ['Parameter', 'Detail']//, 'Example']
+    this.attributes = ['Parameter', 'Detail', 'Example']
+    this.ignore = {
+      resetWidth: ['Example']
+    }
   }
 }