浏览代码

Merge pull request #5041 from wenzhixin/feature/5005

Feature/5005
文翼 5 年之前
父节点
当前提交
b947bc6dc4
共有 2 个文件被更改,包括 48 次插入27 次删除
  1. 22 22
      site/docs/api/table-options.md
  2. 26 5
      src/bootstrap-table.js

+ 22 - 22
site/docs/api/table-options.md

@@ -580,28 +580,6 @@ The table options are defined in `jQuery.fn.bootstrapTable.defaults`.
 
 - **Example:** [Ignore Click To Select On](https://examples.bootstrap-table.com/#options/ignore-click-to-select-on.html)
 
-## locale
-
-- **Attribute:** `data-locale`
-
-- **Type:** `String`
-
-- **Detail:**
-
-  Sets the locale to use (i.e. `'zh-CN'`). Locale files must be pre-loaded.
-  Allows for fallback locales, if loaded, in the following order:
-
-  * First tries for the locale as specified,
-  * Then tries the locale with '_' translated to '-' and the region code upper cased,
-  * 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, use the last locale loaded (or `'en-US'` if no locale files loaded).
-
-- **Default:** `undefined`
-
-- **Example:** [Table Locale](https://examples.bootstrap-table.com/#options/table-locale.html)
-
 ## loadingFontSize
 
 - **Attribute:** `data-loading-font-size`
@@ -642,6 +620,28 @@ The table options are defined in `jQuery.fn.bootstrapTable.defaults`.
 
 - **Example:** [Loading Template](https://examples.bootstrap-table.com/#options/loading-template.html)
 
+## locale
+
+- **Attribute:** `data-locale`
+
+- **Type:** `String`
+
+- **Detail:**
+
+  Sets the locale to use (i.e. `'zh-CN'`). Locale files must be pre-loaded.
+  Allows for fallback locales, if loaded, in the following order:
+
+  * First tries for the locale as specified,
+  * Then tries the locale with '_' translated to '-' and the region code upper cased,
+  * 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, use the last locale loaded (or `'en-US'` if no locale files loaded).
+
+- **Default:** `undefined`
+
+- **Example:** [Table Locale](https://examples.bootstrap-table.com/#options/table-locale.html)
+
 ## maintainMetaData
 
 - **Attribute:** `data-maintain-meta-data`

+ 26 - 5
src/bootstrap-table.js

@@ -527,13 +527,13 @@ class BootstrapTable {
 
       toggle: `<button class="${this.constants.buttonsClass}" type="button" name="toggle"
         aria-label="Toggle" title="${opts.formatToggle()}">
-        ${opts.showButtonIcons ? Utils.sprintf(this.constants.html.icon, opts.iconsPrefix, opts.icons.toggleOff) : '' }
+        ${opts.showButtonIcons ? Utils.sprintf(this.constants.html.icon, opts.iconsPrefix, opts.icons.toggleOff) : ''}
         ${opts.showButtonText ? opts.formatToggleOn() : ''}
         </button>`,
 
       fullscreen: `<button class="${this.constants.buttonsClass}" type="button" name="fullscreen"
         aria-label="Fullscreen" title="${opts.formatFullscreen()}">
-        ${opts.showButtonIcons ? Utils.sprintf(this.constants.html.icon, opts.iconsPrefix, opts.icons.fullscreen) : '' }
+        ${opts.showButtonIcons ? Utils.sprintf(this.constants.html.icon, opts.iconsPrefix, opts.icons.fullscreen) : ''}
         ${opts.showButtonText ? opts.formatFullscreen() : ''}
         </button>`,
 
@@ -951,9 +951,8 @@ class BootstrapTable {
 
     pageList = pageList.map(value => {
       if (typeof value === 'string') {
-        return value.toLowerCase() === opts.formatAllRows().toLowerCase() ||
-          ['all', 'unlimited'].includes(value.toLowerCase())
-          ? opts.formatAllRows() : +value
+        return (value.toLowerCase() === opts.formatAllRows().toLowerCase() ||
+          ['all', 'unlimited'].includes(value.toLowerCase())) ? opts.formatAllRows() : +value
       }
       return value
     })
@@ -1653,6 +1652,28 @@ class BootstrapTable {
       }
     }
 
+    if (
+      this.options.search &&
+      this.options.sidePagination === 'server' &&
+      this.columns.filter(column => !column.searchable).length
+    ) {
+      params.searchable = []
+
+      for (const column of this.columns) {
+        if (
+          !column.checkbox &&
+          column.searchable &&
+          (
+            this.options.visibleSearch &&
+            column.visible ||
+            !this.options.visibleSearch
+          )
+        ) {
+          params.searchable.push(column.field)
+        }
+      }
+    }
+
     if (!(Utils.isEmptyObject(this.filterColumnsPartial))) {
       params.filter = JSON.stringify(this.filterColumnsPartial, null)
     }