Browse Source

Added switchableLabel column option

Marcel Overdijk 2 years ago
parent
commit
b4623fb1c2
5 changed files with 19 additions and 1 deletions
  1. 1 0
      CHANGELOG.md
  2. 1 0
      index.d.ts
  3. 15 0
      site/docs/api/column-options.md
  4. 1 1
      src/bootstrap-table.js
  5. 1 0
      src/constants/index.js

+ 1 - 0
CHANGELOG.md

@@ -6,6 +6,7 @@ ChangeLog
 #### Core
 
 - **New:** Added `sortBy` method.
+- **New:** Added `switchableLabel` column option.
 
 #### Extensions
 

+ 1 - 0
index.d.ts

@@ -63,6 +63,7 @@ export interface BootstrapTableColumn {
   checkbox?: boolean;
   halign?: any;
   switchable?: boolean;
+  switchableLabel?: any;
   class?: any;
   escape?: boolean;
   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)
 
+## 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
 
 - **Attribute:** `data-title`

+ 1 - 1
src/bootstrap-table.js

@@ -724,7 +724,7 @@ class BootstrapTable {
             if (column.switchable) {
               html.push(Utils.sprintf(this.constants.html.toolbarDropdownItem,
                 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++
             }
           })

+ 1 - 0
src/constants/index.js

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