浏览代码

Merge branch 'develop' into feature/button-class-attribute3

Marcel Overdijk 2 年之前
父节点
当前提交
7ec8584c00

+ 1 - 0
CHANGELOG.md

@@ -6,6 +6,7 @@ ChangeLog
 #### Core
 #### Core
 
 
 - **New:** Added `sortBy` method.
 - **New:** Added `sortBy` method.
+- **New:** Added `switchableLabel` column option.
 - **Update** Added support for `class` attribute in toolbar buttons.
 - **Update** Added support for `class` attribute in toolbar buttons.
 
 
 #### Extensions
 #### Extensions

+ 1 - 0
index.d.ts

@@ -63,6 +63,7 @@ export interface BootstrapTableColumn {
   checkbox?: boolean;
   checkbox?: boolean;
   halign?: any;
   halign?: any;
   switchable?: boolean;
   switchable?: boolean;
+  switchableLabel?: string;
   class?: any;
   class?: any;
   escape?: boolean;
   escape?: boolean;
   events?: BootstrapTableEvents;
   events?: BootstrapTableEvents;

+ 15 - 0
site/docs/api/column-options.md

@@ -437,6 +437,21 @@ The column options is defined in `jQuery.fn.bootstrapTable.columnDefaults`.
 
 
 - **Example:** [Column Switchable](https://examples.bootstrap-table.com/#column-options/switchable.html)
 - **Example:** [Column Switchable](https://examples.bootstrap-table.com/#column-options/switchable.html)
 
 
+## switchableLabel
+
+- **Attribute:** `data-switchable-label`
+
+- **Type:** `String`
+
+- **Detail:**
+
+  The label of the switchable column in the dropdown. If not specified uses the column title.
+
+- **Default:** `undefined`
+
+- **Example:** [Column Switchable](https://examples.bootstrap-table.com/#column-options/switchable.html)
+
+
 ## title
 ## title
 
 
 - **Attribute:** `data-title`
 - **Attribute:** `data-title`

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

@@ -1379,7 +1379,7 @@ The table options are defined in `jQuery.fn.bootstrapTable.defaults`.
 
 
 - **Detail:**
 - **Detail:**
 
 
-  Set `true` to show the columns drop down list. We can set the [`switchable`](/docs/api/column-options/#switchable) column option to `false` to hide the columns item in the drop down list.
+  Set `true` to show the columns drop down list. We can set the [`switchable`](/docs/api/column-options/#switchable) column option to `false` to hide the columns item in the drop down list. The minimum number of selected columns can be controlled with the [minimumCountColumns](/docs/api/table-options/#minimumcountcolumns) table option.
 
 
 - **Default:** `false`
 - **Default:** `false`
 
 

+ 2 - 2
src/bootstrap-table.js

@@ -670,7 +670,7 @@ class BootstrapTable {
         html: () => {
         html: () => {
           const html = []
           const html = []
 
 
-          html.push(`<div class="keep-open ${this.constants.classes.buttonsDropdown}" title="${opts.formatColumns()}">
+          html.push(`<div class="keep-open ${this.constants.classes.buttonsDropdown}">
             <button class="${this.constants.buttonsClass} dropdown-toggle" type="button" ${this.constants.dataToggle}="dropdown"
             <button class="${this.constants.buttonsClass} dropdown-toggle" type="button" ${this.constants.dataToggle}="dropdown"
             aria-label="${opts.formatColumns()}" title="${opts.formatColumns()}">
             aria-label="${opts.formatColumns()}" title="${opts.formatColumns()}">
             ${opts.showButtonIcons ? Utils.sprintf(this.constants.html.icon, opts.iconsPrefix, opts.icons.columns) : ''}
             ${opts.showButtonIcons ? Utils.sprintf(this.constants.html.icon, opts.iconsPrefix, opts.icons.columns) : ''}
@@ -724,7 +724,7 @@ class BootstrapTable {
             if (column.switchable) {
             if (column.switchable) {
               html.push(Utils.sprintf(this.constants.html.toolbarDropdownItem,
               html.push(Utils.sprintf(this.constants.html.toolbarDropdownItem,
                 Utils.sprintf('<input type="checkbox" data-field="%s" value="%s"%s%s> <span>%s</span>',
                 Utils.sprintf('<input type="checkbox" data-field="%s" value="%s"%s%s> <span>%s</span>',
-                  column.field, i, checked, disabled, column.title)))
+                  column.field, i, checked, disabled, column.switchableLabel ? column.switchableLabel : column.title)))
               switchableCount++
               switchableCount++
             }
             }
           })
           })

+ 1 - 0
src/constants/index.js

@@ -442,6 +442,7 @@ const COLUMN_DEFAULTS = {
   sorter: undefined,
   sorter: undefined,
   visible: true,
   visible: true,
   switchable: true,
   switchable: true,
+  switchableLabel: undefined,
   cardVisible: true,
   cardVisible: true,
   searchable: true,
   searchable: true,
   formatter: undefined,
   formatter: undefined,

+ 15 - 16
src/extensions/editable/bootstrap-table-editable.js

@@ -48,7 +48,6 @@ $.BootstrapTable = class extends $.BootstrapTable {
       }
       }
 
 
       const editableOptions = {}
       const editableOptions = {}
-      const editableDataMarkup = []
       const editableDataPrefix = 'editable-'
       const editableDataPrefix = 'editable-'
       const processDataOptions = (key, value) => {
       const processDataOptions = (key, value) => {
         // Replace camel case with dashes.
         // Replace camel case with dashes.
@@ -77,26 +76,26 @@ $.BootstrapTable = class extends $.BootstrapTable {
 
 
         $.each(column, processDataOptions)
         $.each(column, processDataOptions)
 
 
-        $.each(editableOptions, (key, value) => {
-          editableDataMarkup.push(` ${key}="${value}"`)
-        })
-
-        let noEditFormatter = false
         const editableOpts = Utils.calculateObjectValue(column,
         const editableOpts = Utils.calculateObjectValue(column,
           column.editable, [index, row], {})
           column.editable, [index, row], {})
+        const noEditFormatter = editableOpts.hasOwnProperty('noEditFormatter') &&
+                                editableOpts.noEditFormatter(value, row, index, field)
 
 
-        if (editableOpts.hasOwnProperty('noEditFormatter')) {
-          noEditFormatter = editableOpts.noEditFormatter(value, row, index, field)
+        if (noEditFormatter) {
+          return noEditFormatter
         }
         }
 
 
-        if (noEditFormatter === false) {
-          return `<a href="javascript:void(0)"
-            data-name="${column.field}"
-            data-pk="${row[this.options.idField]}"
-            data-value="${result}"
-            ${editableDataMarkup.join('')}></a>`
-        }
-        return noEditFormatter
+        let editableDataMarkup = ''
+
+        $.each(editableOptions, (key, value) => {
+          editableDataMarkup += ` ${key}="${value}"`
+        })
+
+        return `<a href="javascript:void(0)"
+          data-name="${column.field}"
+          data-pk="${row[this.options.idField]}"
+          data-value="${value || ''}"
+          ${editableDataMarkup}>${result}</a>` // expand all data-editable-XXX
       }
       }
     })
     })
   }
   }

+ 4 - 5
src/extensions/filter-control/utils.js

@@ -113,11 +113,10 @@ export function fixHeaderCSS ({ $tableHeader }) {
 
 
 export function getElementClass ($element) {
 export function getElementClass ($element) {
   return $element.attr('class')
   return $element.attr('class')
-    .replace('form-control', '')
-    .replace('form-select', '')
-    .replace('focus-temp', '')
-    .replace('search-input', '')
-    .trim()
+    .split(' ')
+    .filter(function (className) {
+      return className.startsWith('bootstrap-table-filter-control-')
+    })
 }
 }
 
 
 export function getCursorPosition (el) {
 export function getCursorPosition (el) {

文件差异内容过多而无法显示
+ 606 - 686
yarn.lock