zhixin 6 年 前
コミット
2a65d3f2eb

+ 1 - 1
_config.yml

@@ -29,7 +29,7 @@ algolia:
 # Custom variables
 current_version:  1.14.2
 title:            "Bootstrap Table"
-description:      "An extended table to integration with some of the most widely used CSS frameworks. (Supports Bootstrap, Semantic UI, Bulma, Material Design, Foundation)"
+description:      "An extended table to the integration with some of the most widely used CSS frameworks. (Supports Bootstrap, Semantic UI, Bulma, Material Design, Foundation)"
 authors:          "Zhixin Wen, and Bootstrap Table contributors"
 keywords:         "bootstrap,table,pagination,checkbox,radio,datatables,css,css-framework,semantic,semantic-ui,bulma,material,material-design,materialize,foundation"
 repo:             https://github.com/wenzhixin/bootstrap-table

+ 15 - 2
site/docs/api/localizations.md

@@ -1,7 +1,7 @@
 ---
 layout: docs
 title: Localizations
-description: The Methods API of Bootstrap Table.
+description: The Localizations API of Bootstrap Table.
 group: api
 toc: true
 ---
@@ -38,6 +38,16 @@ $('#table').bootstrapTable({
 })
 {% endhighlight %}
 
+You can custom the format localizations, the calling syntax:
+
+{% highlight javascript %}
+$('#table').bootstrapTable({
+  formatName: function () {
+    return 'Format message'
+  }
+})
+{% endhighlight %}
+
 ## formatLoadingMessage
 
 - **Parameter:** `undefined`
@@ -76,6 +86,10 @@ $('#table').bootstrapTable({
 
 ## formatPaginationSwitch
 
+- **Parameter:** `undefined`
+
+- **Default:** `'Hide/Show pagination'`
+
 ## formatRefresh
 
 - **Parameter:** `undefined`
@@ -104,4 +118,3 @@ $('#table').bootstrapTable({
 - **Parameter:** `undefined`
 
 - **Default:** `'All'`
-

+ 20 - 2
site/docs/api/methods.md

@@ -191,6 +191,15 @@ The calling method syntax: `$('#table').bootstrapTable('method', parameter)`.
 
 ## refreshColumnTitle
 
+- **Parameter:** `params`
+
+- **Detail:**
+
+  Refresh the field title of column, the params contain following properties:
+
+  * `field`: the field name.
+  * `title`: the field title.
+
 ## checkAll
 
 - **Parameter:** `undefined`
@@ -366,7 +375,6 @@ The calling method syntax: `$('#table').bootstrapTable('method', parameter)`.
         }
         ```
 
-
 - **Detail:**
 
   (Can use only in client-side) Filter data in table.
@@ -388,7 +396,6 @@ The calling method syntax: `$('#table').bootstrapTable('method', parameter)`.
         - Filters
     - Return `true` to keep the row and return `false` to filter the row.
 
-
 ## scrollTo
 
 - **Parameter:** `value|object`
@@ -491,17 +498,28 @@ The calling method syntax: `$('#table').bootstrapTable('method', parameter)`.
 
 ## expandAllRows
 
+- **Parameter:** `undefined`
+
 - **Detail:**
 
   Expand all rows if the detail view option is set to `true`.
 
 ## collapseAllRows
 
+- **Parameter:** `undefined`
+
 - **Detail:**
 
   Collapse all rows if the detail view option is set to `true`.
+
 ## updateFormatText
 
+- **Parameter:** `formatName, text`
+
+- **Detail:**
+
+  Update the localizations format text.
+
 ## updateCellById
 
 - **Parameter:** `params`

+ 47 - 13
site/docs/api/table-options.md

@@ -136,10 +136,10 @@ The table options are defined in `jQuery.fn.bootstrapTable.defaults`.
 
   * First tries for the locale as specified,
   * Then tries the locale with '_' translated to '-' and the region code upper cased,
-  * Then tries the the short locale code (i.e. `'zh'` instead of `'fr-CA'`),
+  * Then tries the short locale code (i.e. `'zh'` instead of `'zh-CN'`),
   * And finally will use the last locale file loaded (or the default locale if no locales loaded).
 
-  If left `undefined` or an empty string, uses the last locale loaded (or `'en-US'` if no locale files loaded).
+  If left `undefined` or an empty string, use the last locale loaded (or `'en-US'` if no locale files loaded).
 
 - **Default:** `undefined`
 
@@ -181,7 +181,7 @@ The table options are defined in `jQuery.fn.bootstrapTable.defaults`.
 
 - **Detail:**
 
-  Set `false` to sort the data with loading message. This options works when the sidePagination option is set to `'server'`.
+  Set `false` to sort the data with the loading message. This options works when the sidePagination option is set to `'server'`.
 
 - **Default:** `true`
 
@@ -251,7 +251,7 @@ The table options are defined in `jQuery.fn.bootstrapTable.defaults`.
 
 - **Detail:**
 
-  The custom sort function is executed instead of built-in sort function, takes three parameters:
+  The custom sort function is executed instead of the built-in sort function, takes three parameters:
 
   * `sortName`: the sort name.
   * `sortOrder`: the sort order.
@@ -468,7 +468,7 @@ The table options are defined in `jQuery.fn.bootstrapTable.defaults`.
 
 - **Detail:**
 
-  The field from the json response which will used for showExtendedPagination.
+  The field from the json response which will used for `showExtendedPagination`.
 
 - **Default:** `totalNotFiltered`
 
@@ -525,7 +525,7 @@ The table options are defined in `jQuery.fn.bootstrapTable.defaults`.
 - **Detail:**
 
   Set `true` to show a extended version of pagination (including the count of all rows with out filters).
-  If you use pagination on the server side pls use totalNotFilteredField to define the count.
+  If you use pagination on the server side pls use `totalNotFilteredField` to define the count.
 
 - **Default:** `false`
 
@@ -556,7 +556,7 @@ The table options are defined in `jQuery.fn.bootstrapTable.defaults`.
   Defines the side pagination of the table, can only be `'client'` or `'server'`.
   Using `'server'` side requires either setting the `'url'` or `'ajax'` option.
 
-  Note that the required server response format is different depending on whether the `'client'` or `'server'` option is specified. See the following examples:
+  Note that the required server response format is different depending on whether the  `'sidePagination'` option is set to `'client'` or `'server'`. See the following examples:
 
   * [Without server-side pagination](https://github.com/wenzhixin/bootstrap-table-examples/blob/master/json/data1.json)
   * [With server-side pagination](https://github.com/wenzhixin/bootstrap-table-examples/blob/master/json/data2.json)
@@ -579,6 +579,16 @@ The table options are defined in `jQuery.fn.bootstrapTable.defaults`.
 
 ## totalNotFiltered
 
+- **Attribute:** `data-total-not-filtered`
+
+- **Type:** `Number`
+
+- **Detail:**
+
+  This property is mainly passed in by pagination server, which is easy to use.
+
+- **Default:** `0`
+
 ## pageNumber
 
 - **Attribute:** `data-page-number`
@@ -727,7 +737,7 @@ The table options are defined in `jQuery.fn.bootstrapTable.defaults`.
 
 - **Detail:**
 
-  Calculate and show intermediate pages for quick access
+  Calculate and show intermediate pages for quick access.
 
 - **Default:** `false`
 
@@ -748,7 +758,7 @@ The table options are defined in `jQuery.fn.bootstrapTable.defaults`.
     Example: Github contains git.
   - The value must be identical to the search query.
     Example: Github (value) and Github (search query).
-  - Comparisons (<, >, <=, =<, >=, =>)
+  - Comparisons (<, >, <=, =<, >=, =>).
     Example: 4 is larger than 3.
 
 - **Default:** `false`
@@ -907,7 +917,7 @@ The table options are defined in `jQuery.fn.bootstrapTable.defaults`.
 
   * `column`: the column object.
 
-  Support classes or css. Example usage:
+  Support `classes` or `css`. Example usage:
 
   {% highlight javascript %}
   function footerStyle(column) {
@@ -1036,6 +1046,18 @@ The table options are defined in `jQuery.fn.bootstrapTable.defaults`.
 
 ## filterOptions
 
+- **Attribute:** `data-filter-options`
+
+- **Type:** `Boolean`
+
+- **Detail:**
+
+  Define the default filter options of algorithm, `filterAlgorithm: 'and'` means all given filter must match, `filterAlgorithm: 'or'` means one of the given filter must match.
+
+- **Default:** `{ filterAlgorithm: 'and' }`
+
+- **Example:** [Filter Options](https://examples.bootstrap-table.com/#options/filter-options.html)
+
 ## idField
 
 - **Attribute:** `data-id-field`
@@ -1132,7 +1154,7 @@ The table options are defined in `jQuery.fn.bootstrapTable.defaults`.
 
 - **Detail:**
 
-  Set `true` to maintain the following meta data on change page and search
+  Set `true` to maintain the following meta data on change page and search:
    * selected rows
    * hidden rows
 
@@ -1232,7 +1254,7 @@ The table options are defined in `jQuery.fn.bootstrapTable.defaults`.
 
 - **Detail:**
 
-  Format your detail view when detailView is set to true. Return a String and it will be appended into the detail view cell, optionally render the element directly using the third parameter which is a jQuery element of the target cell.
+  Format your detail view when `detailView` is set to `true`. Return a String and it will be appended into the detail view cell, optionally render the element directly using the third parameter which is a jQuery element of the target cell.
 
 - **Default:** `function(index, row, element) { return '' }`
 
@@ -1246,7 +1268,7 @@ The table options are defined in `jQuery.fn.bootstrapTable.defaults`.
 
 - **Detail:**
 
-  Enable expansion per row when detailView is set to true. Return true and the row will be enabled for expansion, return false and expansion for the row will be disabled. Default function returns true to enable expansion for all rows.
+  Enable expansion per row when `detailView` is set to `true`. Return true and the row will be enabled for expansion, return false and expansion for the row will be disabled. Default function returns true to enable expansion for all rows.
 
 - **Default:** `function(index, row) { return true }`
 
@@ -1310,6 +1332,18 @@ The table options are defined in `jQuery.fn.bootstrapTable.defaults`.
 
 ## buttonsPrefix
 
+- **Attribute:** `data-buttons-prefix`
+
+- **Type:** `String`
+
+- **Detail:**
+
+  Defines prefix of table buttons.
+
+- **Default:** `'btn'`
+
+- **Example:** [Buttons Prefix](https://examples.bootstrap-table.com/#options/buttons-prefix.html)
+
 ## buttonsClass
 
 - **Attribute:** `data-buttons-class`

+ 1 - 1
site/docs/getting-started/browsers-devices.md

@@ -10,7 +10,7 @@ toc: true
 
 Bootstrap Table supports the **latest, stable releases** of all major browsers and platforms. On Windows, **we support Internet Explorer 10-11 / Microsoft Edge**.
 
-Alternative browsers which use the latest version of WebKit, Blink, or Gecko, whether directly or via the platform's web view API, are not explicitly supported. However, Bootstrap should (in most cases) display and function correctly in these browsers as well. More specific support information is provided below.
+Alternative browsers which use the latest version of WebKit, Blink, or Gecko, whether directly or via the platform's web view API, are not explicitly supported. However, Bootstrap Table should (in most cases) display and function correctly in these browsers as well. More specific support information is provided below.
 
 You can find our supported range of browsers and their versions [in our `.browserslistrc file`]({{ site.repo }}/blob/{{ site.current_version }}/.browserslistrc):
 

+ 8 - 7
src/bootstrap-table.js

@@ -2662,13 +2662,14 @@ class BootstrapTable {
     }
   }
 
-  updateFormatText (name, text) {
-    if (this.options[Utils.sprintf('format%s', name)]) {
-      if (typeof text === 'string') {
-        this.options[Utils.sprintf('format%s', name)] = () => text
-      } else if (typeof text === 'function') {
-        this.options[Utils.sprintf('format%s', name)] = text
-      }
+  updateFormatText (formatName, text) {
+    if (!/^format/.test(formatName) || !this.options[formatName]) {
+      return
+    }
+    if (typeof text === 'string') {
+      this.options[formatName] = () => text
+    } else if (typeof text === 'function') {
+      this.options[formatName] = text
     }
     this.initToolbar()
     this.initPagination()

+ 1 - 1
src/constants/index.js

@@ -173,7 +173,7 @@ const DEFAULTS = {
   smartDisplay: true,
   escape: false,
   filterOptions: {
-    'filterAlgorithm': 'and' // and means all given filter must match, or means one of the given filter must match
+    filterAlgorithm: 'and'
   },
   idField: undefined,
   selectItemName: 'btSelectItem',

+ 2 - 0
tools/check-api.js

@@ -14,7 +14,9 @@ class API {
     const lines = content.split('## ')
     const outLines = lines.slice(0, 1)
 
+    console.log('-------------------------')
     console.log(`Checking file: ${file}`)
+    console.log('-------------------------')
 
     for (const item of lines.slice(1)) {
       md[item.split('\n')[0]] = item